Ok so can someone help me with adding exponants to a caculator
Ok so can someone help me with adding exponants to a caculator
Verbal Irony >>
"I love english homework!" When really nobody like english homework.
-Mrs. Jennifer Lenz (English Teacher)
how about
double exp (double) from the <math.h> library
that is e to the power of x .
Other functions at
http://www.opengroup.org/onlinepubs/...sh/math.h.html
Just make a loop out of it, something like this:
That will calculate the value Base to the power of Exp, and puts teh calculated value in Result. That doesn't account for exponents that are less than or equal to 0 (5^0 or 5^-24). But you can easily modify the result to get that.Code:int Base = 2, Exp = 5, ctr, Result; Result = Base; for (ctr = 0; ctr < Exp; ctr++) { Result *= Base; }
So, do you understand everything you know about this yet?
"Begin at the beginning," the King said, very gravely, "and go on till you come to the end; then stop."
Math.h is a header, not a library. And don't use math.h (it's deprecated).Originally Posted by wgdb198
Instead, use cmath and the std namespace.