Hey guys, i can't figure this out. I have a c++ book but it doesn't really help me on this...
I need to compute things such as
3^2 = 9 (three squared = 9)
5^2 = 25 (5 squared = 25)
e^2 = 7.389 (e on calculator)
e ^ 1/2 = 1.64
here is what I have:, but it's not working
#include<iostream>
using namespace std;
int main()
double answer;
double x;
cin>>x;
answer = (x^2);
cout<<answer;
return 0;
}
basically I want to be able to replace "answer" with functions like i mentioned above.
make sure to include
#include<cmath>
before using the pow operataor
z= pow(x,y);
means z = to x raised to the power of y