C cbrt()

The cbrt() function computes the cube root of a number.

Function prototype of cbrt()

double cbrt( double arg );

The function cbrt() takes a single argument (in double) and returns the cube root (also in double).

[Mathematics]  ∛x = cbrt(x) [In C Programming]

The cbrt() function is defined in math.h header file.


To find the cube root of type int, float or long double, you can explicitly convert the type to double using cast operator.

int x = 0;
double result;
result = cbrt(double(x));

Also, you can use cbrtf() function to work specifically with float and cbrtl() to work with long double type.

long double cbrtl(long double arg );
float cbrtf(float arg );

Example: C cbrt() Function

#include <stdio.h>
#include <math.h>

int main()
{
    double num = 6, cubeRoot;

    cubeRoot =  cbrt(num);
    printf("Cube root of %lf =  %lf", num, cubeRoot);

    return 0;
}

Output

Cube root of 6.000000 =  1.817121