By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Forums - General - Borland C++ Excersise help.

You can use pow, just inverse the exponent.

For example, a root can also be written as x^(1/y), so for a cubed root you'd do something like pow (x, 1 / 3)



Around the Network
noslodecoy said:

You can use pow, just inverse the exponent.

For example, a root can also be written as x^(1/y), so for a cubed root you'd do something like pow (x, 1 / 3)


dunno why, but the answer always ends up being 1



morenoingrato said:
noslodecoy said:

You can use pow, just inverse the exponent.

For example, a root can also be written as x^(1/y), so for a cubed root you'd do something like pow (x, 1 / 3)


dunno why, but the answer always ends up being 1


Sorry, using 1/3 as the second parameter gives it the idea that the value should be evaluated as an integer, when it should be a float.  try pow(x, 1.0 / 3.0 )

edit: for clarification, when 1/3 is evaluated as an integer, it returns 0.  Anything to the 0 power will be one.  Therefore, the reason you are getting one is that x^0 will always be solved as 1.