# C Program to Calculate Cube Root of a Number

In this post, we will learn how to calculate the cube root of a number using the C Programming language.

The cube root of a number is the factor that we multiply by itself three times to get that number. For example, the cube root of 64 is 4 since 4 x 4 x 4 = 64.

We will calculate the cube root using the cbrt() function.

So, without further ado, let’s begin this tutorial.

## C Program to Calculate Cube Root of a Number

```// C Program to Calculate Cube Root of a Number
#include <stdio.h>
#include <math.h>
int main(){
int number, root;

printf("Enter a number: ");
scanf("%d", &number);

// Calculating cube root using cbrt() Function
root = cbrt(number);

// Displaying output
printf("Cube root of %d is: %d", number, root);
return 0;
}
```

Output

``````Enter a number: 125
Cube root of 125 is: 5
``````

## How Does This Program Work ?

```    int number, root;
```

In this program, we have declared two integer data type variables named number and root.

```    // Asking for input
printf("Enter a number: ");
scanf("%d", &number);
```

Then, the user is asked to enter a number to find it’s cube root. The entered value gets stored in the number named variable.

```    // Calculating cube root using cbrt() Function
root = cbrt(number);
```

The cbrt() function takes a single argument and returns the cube root of the number. The cbrt() function is defined in the math.h header file.

```    // Displaying output
printf("Cube root of %d is: %d", number, root);
```

The cube root of the entered number is displayed on the screen using printf() function.

## Conclusion

I hope after going through this post, you understand how to calculate the cube root of a number using the C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to assist you.