-
Square Root
How would I get the square root in C++, do I have to use a function or something? I am using it for A*A + B*B = C*C, but I want to square root C so it is just C (this is the Pythagoreum Therom if I am not mistaken, except that it uses square root signs, the little 2s, but I don't know how to make them :) ). Any help is appreciated and needed.
-
Yeah there's a function for that:
Prototype: double sqrt(double num);
Header file: math.h
PHP Code:
/*Start of code*/
#include <math.h>
#include <iostream.h>
int main(void)
{
double num = 9.0;
cout << "The square root of " << num << "is " << sqrt(num);
return 0;
}
/*End of code*/
:cool:
-
Great, thanks tons. That will help me out alot.
-
-
You could also use this:
double pow(double x,double y);
It raises x to the power of y, and returns the result.
Include math.h
e.g. pow(number,0.5);
-