![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2004
Location: Hampshire
Posts: 56
Rep Power: 5
![]() |
How would i work out the squareroot of a number in C++?
Example: The number is 25, how would i work out the sqareroot of 25 is 5 using C++? |
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
#include <math.h>
int main(void)
{
.........
.........
...............
double x = sqrt(25);
}I think that should work.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jul 2004
Location: Hampshire
Posts: 56
Rep Power: 5
![]() |
Thank you
![]() I'm attempting to learn C++ ![]() I have decided i would make a program to work out quadratic formula questions. I'm getting there slowly ![]() |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
I'm always making math programs in C.....I really need to make one that assists in my accounting homework
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
My professor called the square root function "squirt".... He also referred to gigabytes as "bubbabytes" I guess its a southern thing
.sqrt() will get what ya need.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#6 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
Our computer engineering teachern's name is Mr. Festchyn....We sometimes call him F Diddy B) Last year we had an electronic scrolling sign and it said 'F Diddy is the shiz'
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Sep 2004
Posts: 38
Rep Power: 0
![]() |
If you just want the answer then use the math.h function, if you are interested in how to actually determine the square root of a number you should do a google search of "newton's method" and "square root" - writing a program that does this is one of those rites of passage you will probably do in your CS courses eventually.
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Oct 2004
Posts: 8
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: Sep 2004
Location: JHB , South Africa
Posts: 79
Rep Power: 4
![]() |
I doubt that, I would bet its coded in assembler. You would be able to see the definition of the function but thats about it :/
__________________
Ravilj's OpenGL Terrain aka WinTerrain Last Updated: 17/01/2005! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|