Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library


The C++ <cmath> cbrt() function is used to return 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 below example, 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