cbrt()

The cbrt() function 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
}
Looking to contribute?

Learn C++ on Codecademy