C++ Standard Library C++ STL Library

C++ <cmath> - cbrt() Function



The C++ <cmath> cbrt() function returns the cube root of the given number.

Syntax

double cbrt (double x);
float cbrt (float x);
long double cbrt (long double x);
double cbrt (T x);                    

Parameters

x Specify a number.

Return Value

Returns the cube root of the specified number.

Example:

In the example below, cbrt() function is used to find out the cube root of the given number.

#include <iostream>
#include <cmath>
using namespace std;
 
int main (){
  cout<<cbrt(25)<<"\n";
  cout<<cbrt(30)<<"\n";
  cout<<cbrt(35.5)<<"\n";
  cout<<cbrt(-25)<<"\n";  
  return 0;
}

The output of the above code will be:

2.92402
3.10723
3.28657
-2.92402

❮ C++ <cmath> Library