[Mathematics] ∛x = cbrt(x) [In C Programming]
This function is defined in <cmath> header file.
cbrt() prototype [As of C++ 11 standard]
double cbrt(double x); float cbrt(float x); long double cbrt(long double x); double cbrt(T x); // For integral type
cbrt() Parameters
The cbrt() function takes a single argument whose cube root is to be calculated.
cbrt() Return value
The cbrt() function returns the cube root of the given argument.
Example 1: How cbrt() works in C++?
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = -1000.0, result;
result = cbrt(x);
cout << "Cube root of " << x << " is " << result << endl;
return 0;
}
When you run the program, the output will be:
Cube root of -1000 is -10
Example 2: cbrt() function With integral Argument
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long x = 964353422;
double result = cbrt(x);
cout << "Cube root of " << x << " is " << result << endl;
return 0;
}
When you run the program, the output will be:
Cube root of 964353422 is 987.974