# Cubic-Roots in C++

Page 1 of 1

## 3 Replies - 16901 Views - Last Post: 10 December 2009 - 07:24 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=144633&amp;s=ae191a9c97b91eaf9614e881dbbb7915&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 KoenM

Reputation: -4
• Posts: 41
• Joined: 07-December 09

# Cubic-Roots in C++

Posted 10 December 2009 - 01:25 AM

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

Is This A Good Question/Topic? 0

## Replies To: Cubic-Roots in C++

### #2 EdwinNameless

Reputation: 128
• Posts: 723
• Joined: 15-October 09

## Re: Cubic-Roots in C++

Posted 10 December 2009 - 02:15 AM

KoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

It's always possible to get the cubic root in any language if you have an exponentiation function: you just have to remember that cubic root is actually bringing a number to the power 1/3.

```#include <iostream>
#include <cmath>
int main() {
float i = 125.0;
std::cout << pow(i,(1/3.0))  << std::endl;
}

```

This post has been edited by EdwinNameless: 10 December 2009 - 02:23 AM

### #3 KoenM

Reputation: -4
• Posts: 41
• Joined: 07-December 09

## Re: Cubic-Roots in C++

Posted 10 December 2009 - 03:01 AM

EdwinNameless, on 10 Dec, 2009 - 01:15 AM, said:

KoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?

It's always possible to get the cubic root in any language if you have an exponentiation function: you just have to remember that cubic root is actually bringing a number to the power 1/3.

```#include <iostream>
#include <cmath>
int main() {
float i = 125.0;
std::cout << pow(i,(1/3.0))  << std::endl;
}

```

Thanks!
I will try this.

• Saucy!

Reputation: 6246
• Posts: 24,014
• Joined: 23-August 08

## Re: Cubic-Roots in C++

Posted 10 December 2009 - 07:24 AM

EdwinNameless, on 10 Dec, 2009 - 04:15 AM, said:

KoenM, on 10 Dec, 2009 - 07:25 AM, said:

Hello,

Does anybody here know how I can put a cubic-root in C++?
Or is this impossible to do?