Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
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
Did you find this article helpful?