The C cbrt function is one of the Math Function, used to find the cube root of a number or a specified expression. The syntax of the cbrt in C Programming is as shown below. The following function will accept a positive value and returns the cube root of it.
double cbrt(double number);
C cbrt Function Example
The math cbrt Function allows you to find the cube root of a given number. In this program, We are going to find the cube root and display the output.
//* CBRT in C Programming Example */ #include <stdio.h> #include <math.h> int main() { printf("\n The Cube Root Value of 0 = %.4f ", cbrt(0)); printf("\n The Cube Root Value of 1 = %.4f ", cbrt(1)); printf("\n The Cube Root Value of 125 = %.4f ", cbrt(125)); printf("\n The Cube Root Value of 500.36 = %.4f ", cbrt(500.36)); printf("\n The Cube Root Value of -27.32 = %.4f ", cbrt(-27.32)); printf("\n The Cube Root Value of -90 = %.4f ", cbrt(-90)); return 0; }
C cube root Example 2
In this C Programming example, we are allowing the user to enter their own value. Next, this program uses the cbrt function to find the cube root of that number.
/* CBRT in C Programming Example */ #include <stdio.h> #include <math.h> int main() { float number, cubeValue; printf(" Please Enter any Numeric Value : "); scanf("%f", &number); cubeValue = cbrt(number); printf("\n The Cube Root Value of %.2f = %.4f ", number, cubeValue); return 0; }
Please Enter any Numeric Value : 125
The Cube Root Value of 125.00 = 5.0000