Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-13-2009, 10:03 AM   PM User | #1
Active X
New Coder

 
Join Date: Aug 2007
Posts: 74
Thanks: 3
Thanked 2 Times in 2 Posts
Active X is an unknown quantity at this point
Smile Mathematical operations in C+=

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.
Active X is offline   Reply With Quote
Old 07-13-2009, 10:45 AM   PM User | #2
it career
Banned

 
Join Date: Jun 2007
Location: Web Designer
Posts: 321
Thanks: 0
Thanked 6 Times in 6 Posts
it career can only hope to improve
pow(number,1.0/3)
it career is offline   Reply With Quote
Old 07-13-2009, 11:13 AM   PM User | #3
BrickInTheWall
Regular Coder

 
BrickInTheWall's Avatar
 
Join Date: Mar 2009
Location: Munich, Germany
Posts: 139
Thanks: 1
Thanked 13 Times in 13 Posts
BrickInTheWall is on a distinguished road
third root of x is the same as x^(1/3) ...
BrickInTheWall is offline   Reply With Quote
Old 07-14-2009, 08:27 AM   PM User | #4
Active X
New Coder

 
Join Date: Aug 2007
Posts: 74
Thanks: 3
Thanked 2 Times in 2 Posts
Active X is an unknown quantity at this point
Yes, I know math so good. But have you tested it ever in your own compiler ?
Active X is offline   Reply With Quote
Old 07-14-2009, 12:05 PM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Try
Code:
#include <stdio.h>
#include<math.h>
void main(){
double x=27;

printf("%lf ",pow(x,(double)1/3));
}
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 07-14-2009, 04:10 PM   PM User | #6
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by abduraooft View Post
Try
Code:
#include <stdio.h>
#include<math.h>
void main(){
double x=27;

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

Code:
printf("%lf ",pow(x,1.0/3.0));
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:44 PM.


Advertisement
Log in to turn off these ads.