×

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.


Related Topics

Booleans in C

Introduction to Boolean With all the complexities of programming, it can take time to understand the basics. One concept, in particular, that confuses many beginners is the use of Booleans in...

6 minutes read.

Variable in C

Variable is an identifier that holds data in memory. It is used to identify input data in a program. The value of the variable can change at the time of...

2 minutes read.

Diffie-Hellman Algorithm in C

Background: A method of public-key encryption known as elliptic curve cryptography (ECC) is based on the algebraic structure of elliptic curves over finite fields. To ensure equal security, ECC encryption requires fewer...

4 minutes read.

Pascal Triangle in C

The pascal triangle in c is an array of binomial coefficients in triangular form. Here the nth row contains the binomial coefficient of ncr.In a pascal triangle, every number is...

2 minutes read.

How to Calculate Time Complexity in C?

What is time complexity? An algorithm's time complexity measures how long it takes to complete a task in relation to the size of the input. It should be noted that the...

5 minutes read.

Float in islower() in C

Introduction: This article briefly discusses the float in islower() in C. The islower() function checks if the input character passed inside the function is lowercase. Lowercase letters include (a-z). The islower()...

4 minutes read.

Execution flow of C program

There are various steps of the execution of the C program that is given below. The following step of the execution Write source codes Preprocess Compile Link edit Load Execute Editor or...

1 minute read.

getch() function in C

getch() is a pre-define or built-in function present in the conio.h library. It returns the given character immediately without waiting for the enter key to be entered. By using getch()...

3 minutes read.

#define in C

#define in C In the C programming language, the preprocessor directive acts an important role within which the #define directive is present that is used to define the constant or the...

3 minutes read.

Entry Control Loop in C

Initially, an entry control loop verifies the termination condition at the entry point. After that, its control passes to the main body of the while or for loop if the...

3 minutes read.

Operators in C

An operator is a special symbol that tells the compiler to perform specific mathematical or logical operations. It is the combination of constants and variables through expressions. Example: int c = a+b*5 Where,...

5 minutes read.

String literals in C

Constants refer to the fixed values of the program that may not alter during the compiling ad execution. These fixed values are known as literals. In other words, the values...

3 minutes read.

C program that does not Suspend when Ctrl+Z is Pressed

In Programming when a program breakdown and runs surprisingly in the terminal compiler the developer has the ability to prevent the program from running unequivocally. For expressly halting the program,...

3 minutes read.

Difference between rand() and srand() function in C

What is the rand()? The rand() means random function. This function is used in C. It generates random numbers in the range of 0 to the RAND_MAX. Suppose we generate a...

3 minutes read.

Header files in C

Header files in C In the C programming language, header files are present, which have an extension of ‘.h’, and it consists of macro definitions, declarations, and so on that are...

4 minutes read.

Flow Chart of Do while loop in C

This is a flowchart that represents the process of executing the Do while loop in the C programming language Generally, as we know there are three main components of Do While...

3 minutes read.

Find Union and Intersection of Two Arrays in C

Union You can find the union of the two sorted arrays using the join merge method on arr1[] and arr2[]. Use two index variables i and j with initial values i =...

4 minutes read.

First Fit Program in C

This is one of the easiest ways to allocate memory. The main goal is to divide the memory into several fixed sizes. In C, there is only one process for...

3 minutes read.

C pre-processor

The C processor is a macro processor which is used to compile the source code of the program (step by step) . It is not a part of the compiler....

4 minutes read.

File Handling in C

File Handling is used to open, read, write, search and close file.  C files I/O functions handles data on secondary storage device. File handling function: There are varioushandling functions in C. Function Operation fopen() It is...

4 minutes read.