How do you get the cube root of something?
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
Cube Roots
try this, im a begginer at C++ kinda, but I think this would work...
then use like
I think that should work..
Edited by - uG on August 30, 2000 7:08:38 PM
int cubeRoot(int a){int b = 3int c = 0;for(b=0; b<4; b++){c += a*a}return a;}
then use like
int x = cubeRoot(4);
I think that should work..
Edited by - uG on August 30, 2000 7:08:38 PM
pow( x, .33 )?
in many cases, this will only work if x is positive.
Edited by - Antknei on August 30, 2000 7:10:30 PM
in many cases, this will only work if x is positive.
Edited by - Antknei on August 30, 2000 7:10:30 PM
try this, im a begginer at C++ kinda, but I think this would work...
then use like
I think that should work..
int cubeRoot(int a){int b = 3int c = 0;for(b=1; b<4; b++){c += a*a}return a;}
then use like
int x = cubeRoot(4);
I think that should work..
Your equation ends up with c = 3a^2. but it returns a, which you don''t change. Am I missing something, or did you mistype something?
Like Antknei was saying, to get the nth root of a number x, use pow(x, 1/n). As far as I know, the only time you get an error returned from this function is when you try to raise zero to a negative power, as this would be equivalent to division by zero.
-Ironblayde
Aeon Software
-Ironblayde
Aeon Software
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement