# Cbrt() function in C

### Introduction:

The Cbrt is a function used in C programming language. The cbrt() function is a math function. Using the cbrt function, we can do the cube root of a function.

This function takes a single argument.

It is an in-built function of the C language. In the Cart() function, we give arguments or numbers, and the output is come, which is the cube root of the given arguments.

**Syntax of the cbrt() function in C language:**

Syntax means the order or arrangement in the program. The syntax is also known as the function prototype. Every function has a syntax value. The syntax of the cbrt() function is:

double cbrt = double (number) ;

The cbrt() function gives the cube root of a number by taking a single number or argument.

*Parameters of the cbrt() function in C language:*

In the cbrt() function, we use many parameters like floot, int, and long double. Cart() function is used only for the floot, and the cbrtl() function is used only for long double.

*Example* –

**floot cbrtf (floot number);** it is the use of cbrtf() function

**long double cbrtl (long double number);** it is the use of cbrtl() function

*Returns Value of the cbrt() function in C language:*

The cbrt() function only return the **cube root** of a number. If we give a single number, this function gives the cube root of this number. But if we give an integer of a number, then this function does not give any cube root of the integer. At this time, the function only **doubles the integer value**.

```
Input : 27
Output : 3
Input : 64
Output : 4
```

*Header file of the cbrt() function in C language* :

Every program contains some header files. For the run of any program, you must need a header file. Without a header file, you can't run any programs. So, we must produce the header file in every program.

It is a file with an extension. The cbrt() function only takes a single argument or number.

The primary use of the header file is to propagate the declaration of code files. The cbrt() function uses as a math function. The header file of the cbrt() function in the C language is **<math.h>**.

It writes in the program as **#include <math.h>**.

**Mathematics :**

* 3√x = cbrt (x) *It is the use of cbrt() function in C programming language. It has done the cube root of the given number

**x**.

*What is means by Cube root?*

A cube root is a number we multiply by three times to get the actual number. Example - * 3√27 = 3 *(when we multiply three itself by the three times like {[3*3*3] = 27}, then we get 27. So, 27 is the cube root of a number 3)

*Algorithm of the cbrt() function:*

The algorithm for the cbrt() function is –

* Step 1:* Start the program.

* Step 2:* Take a variable number.

* Step 3:* Pass the number variable to the cube root function.

**(cbrtf(number))**

* Step 4:* This function returns the value. The value is only the cube root of a given number.

* Step 5:* Print the output.

* Step 6:* End the program.

** Example 1** –

Here we given a example of the cbrt() function using C language:

//header file initialize

```
#include <stdio.h>
#include <math.h>
int main()
{
```

//value of the variable

```
double number = 9, cube root;
cube root = cbrt (number);
```

//print the output

```
printf(“Cube root of the number %4f = %5f” , number, cube root);
return 0;
}
```

** Output: **We compile and run the above program.

**The result of this above program is:**

Cube root of the number 9.0000 = 2.08008

*To better understand, we give another example of the cbrt() function.*

*Example 2* –

Here we given a example of the cbrt() function using C language:

```
//header file initialize
#include <stdio.h>
#include <math.h>
int main()
{
float number, Cube root value;
printf(“Write any numerical value: “);
Scanf(“%f”, & number);
Cube root value = cbrt(number);
//print the output
printf(“\n Cube root of the number %2f = %2f” , number, cube root);
return 0;
}
```

**Output: **We compile and run the above program.The result of this above program is:

```
Write any numerical value: 216
Cube root of the number 216.00 = 6.00
```

*In the above two programs, we have used the cbrt() function; by the programs, we briefly discussed how to write any C language program using the cbrt() function. The cbrt() function is a mathematical function.*

*So we <math.h> header file in this program. We also share the output of the above two programs. The output of the two programs is the cube root of the input number or argument.*