Javatpoint Logo
Javatpoint Logo

Floor() Function in C Programming

floor() in Mathematics

The floor() function in mathematics requires a real number, and it computes the greatest integer that can either be less than or equals to the value of x.

floor() in C Programming

It is a function that is defined in math.h header file and other similar functions enable the user to perform certain mathematical operations so easy further computations.

The floor() function takes a value from the user and returns the double value that is less than or equal to the value of x.

Syntax for using floor()

The function's return type is double, which takes a numerical argument. It can also be int, float, or any other datatype that can hold numerical value. Thus, the syntax is as follows:

Implementing floor() in a C Program

Below is the code for implementing the floor() function in C language:

Output:

Floor() Function in C Programming

Explanation:

We have used the function in three different ways in the above program.

We have first directly printed the floor value using the printf() statement without storing the computed value in any variable.

In the second method we have storing the value computed using the variable floor. Then we used the value stored in the variable to print the output.

In the last method, we have directly used a numerical value as the input parameter in the function and have stored the value in the variable, which is to be printed.


Next Topicmemcmp() in C





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA