...

View Full Version : Mathematical operations in C+=



Active X
07-13-2009, 11:03 AM
Hi to you dear professional programmer!

I have a question about Math in C++.

you calculate the second root or "square" root of a number in C++ with sqrt or another function, or with pow(number, 0.5).

How can I calculate the third root ("Cubic" root) of a number ?

Will be so thankful to your helps.

it career
07-13-2009, 11:45 AM
pow(number,1.0/3)

BrickInTheWall
07-13-2009, 12:13 PM
third root of x is the same as x^(1/3) ...

Active X
07-14-2009, 09:27 AM
Yes, I know math so good. But have you tested it ever in your own compiler ?

abduraooft
07-14-2009, 01:05 PM
Try

#include <stdio.h>
#include<math.h>
void main(){
double x=27;

printf("%lf ",pow(x,(double)1/3));
}

oracleguy
07-14-2009, 05:10 PM
Try

#include <stdio.h>
#include<math.h>
void main(){
double x=27;

printf("%lf ",pow(x,(double)1/3));
}

Or


printf("%lf ",pow(x,1.0/3.0));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum