Library Function cbrt in Math Class

Library Function cbrt of math.h Header File in C

In this section, we will discuss about library function cbrt in math class which is used in C.
The C header file math.h contains the standard math library functions that can be used for performing various mathematical operations. The cbrt function returns the cube root of a number.

Library Function cbrt in Math Class

Library Function cbrt of math.h Header File

  • In C programming language the cbrt function is included in math.h header file.
  • The range of input argument which is passed to cbrt function is not limited here as it can be any value from int to float or double but then has to be type casted into double type.

Declaration of cbrt function

double cbrt(double arg) 

Parameters of cbrt function

The cbrt function accepts a single input argument  which is a double value.

Parameter         Description
double value         This value of double function ranges to all positive and negative numbers.

Return value of cbrt function

The cbrt function returns a cube root value and it’s type is double.

ParameterReturn Value
Cube rootIt returns the value in double.

Implementation of Library Function math.h cbrt()

Example 1:

The following code shows the use of cbrt function.

Run
#include<stdio.h>
#include<conio.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

Example 2:

Run
#include<stdio.h>
#include<conio.h> 
int main() {
 double x = 64;
 double y = 125;
 double x1 = cbrt(x);
 double y1 = cbrt(y);
 printf("Cube root of %.2f is %.2f\n", x, x1);
 printf("Cube root of %.2f is %.2f\n", y, y1);
}

Output:

Cube root of 64.00 is 4.00
Cube root of 125.00 is 5.00

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription