how do you find this? i tried this:
but i came up with this:Code:fyards = (area ^ (1/3)); //cube root
63 C:\Dev-Cpp\program2.cpp invalid operands of types `float' and `int' to binary `operator^'
help?
how do you find this? i tried this:
but i came up with this:Code:fyards = (area ^ (1/3)); //cube root
63 C:\Dev-Cpp\program2.cpp invalid operands of types `float' and `int' to binary `operator^'
help?
The power function is in the library <cmath>
And it goes like this:
Code:variable = pow(x,y); //Where x is what you want and y is the power double temp = pow(8,(1.0/3.0) ); //Will get you 2
Alternative, if area is guaranteed to be greater than zero, would be;
Code:fyards = exp(log(area)/3.0);
This is actually what the pow function does.Originally Posted by grumpy
Mathematically it is equivalent. As to it being what the pow() function actually does: that's implementation dependent. I suggest pow() will also do a few other things, otherwise it wouldn't work if the first argument is negative.
Yup.Originally Posted by arjunajay
But the way the question was asked he was using x^y as a notation for "x raised to the power of y".