cbrt()

Returns the cube root of the argument.

Syntax

std::cbrt(n)

Example 1

Use cbrt() to return the cube root of 27:

#include <iostream>
#include <cmath>
int main() {
double x = 27;
double result;
result = std::cbrt(x);
std::cout << "The cube root of " << x << " is " << result << "\n";
// Output: The cube root of 27 is 3
}

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy