C++ Math cbrt
This function is used to find the cube root of a given number.
Consider a argument 'arg' :
Example
Cube root of a number : ∛arg
Syntax
Syntax would be :
Example
double cbrt(double arg);
float cbrt(float arg);
long double cbrt(long double arg);
double cbrt(integral arg);
Parameter
arg : It is the value of float or integer type.
Return value
It returns the cube root of a given number arg.
Example 1
Let's see a simple example when argument 'arg' is of integer type
Example
#include <iostream>
#include<cmath>
using namespace std;
int main()
{ int arg=8;
std::cout << "Cube root of a number is :" <<cbrt(arg);
return 0;
}
Output:
Output
Cube root of a number is :2
Example 2
Let's see a simple example when an argument 'arg' is of float type.
Example
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float arg=12.8;
std::cout << "Cube root of a number is :" <<cbrt(arg);
return 0;
}
Output:
Output
Cube root of a number is :2.33921