cbrt()

garanews's avatar
Published Jul 20, 2021Updated Jul 31, 2023
Contribute to Docs

The cbrt() function returns the cube root of the argument.

Syntax

std::cbrt(n)

Example

Use cbrt() to find the side lengths of a 27 m3 cube:

#include <iostream>
#include <cmath>
int main() {
double V = 27;
double side;
side = std::cbrt(V);
std::cout << "A cube with a volume of " << V << " has a side length of " << side << "\n";
}

This results in the following output:

A cube with a volume of 27 has a side length of 3

Codebyte Example

Use cbrt() to find the cube root of 8:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn C++ on Codecademy