>because there isnt an opperation in c++ for exponents
There isn't? I think there is.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
#include
pow(base, exponent);
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
a_variable_float = pow(a,b);
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
so like this?
What I meant was:
Declare another float or better yet a double variable at the begining of
main. Then assign the result of the pow function to that variable.
Then do what you wish with that result that is in the variable. :)
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
What you are doing is:
2^5 = 2 * 2 * 2 * 2 * 2 = 32
That is correct.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float a,b,c;
a=0;
b=0;
c=0;
cout<<"enter base"<<endl;
cin>>a;
cout<<"enter power"<<endl;
cin>>b;
pow(a,b); /* you don't need this here */
c = pow(a,b);
cout<<c;
system ("pause");
}
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
o ya your right thats weaird my computter calculator is messed up or something o waite lol no i was doing a logarithmic function i think
Yeah, it helps to know what you want to do, first. :)
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218