Hihi. I'm in the middle of learning C++. Can any of you tell me how to get the square root of something? Like, in VB, you put Sqr(numberGoezHere). how do you do that in C++? and then, how do you raise something to a power?
Printable View
Hihi. I'm in the middle of learning C++. Can any of you tell me how to get the square root of something? Like, in VB, you put Sqr(numberGoezHere). how do you do that in C++? and then, how do you raise something to a power?
The mathematical functions are in math.h, but if you're using the Standard Library (like most of us :p), they're then in cmath:
To raise to a power, use pow.Code:#include <iostream>
#include <cmath>
using namespace std;
void main() {
double x = 5;
cout << sqrt(x) << endl;
}
kewl, thanks ^^