floor function in C programming language
- Home
- function in C
- floor function in C programming language
- On
- By
- 0 Comment
- Categories: function in C, pre-define maths function in C
floor function in C programming language
floor function in C programming language
We will learn about floor function in C programming language
In the C programming Language, the floor() function returns the nearest integer value which is less than or equal to the value for floating point argument to this function
Declaration
Syntax
The syntax of the floor() Arithmetic function in the C programming Language
double floor(double x);
parameters or Argument
x is the parameter or argument of this function( x is a floating point value).
Return value
when a value for x is passed,this function returns the floor value of x, largest integer value which is less than or equal to the passed value
Required Header
In the C programming Language, the required header file for floor() function is
#include <math.h>
Example
The following example explains the usage of floor() function
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { //define the variable double a=12.1,b=12.9,c=-12.1,d=-12.9; //calculate and display the floor value printf("floor value of a: %f\n",floor(a)); printf("floor value of b: %f\n",floor(b)); printf("floor value of c: %f\n",floor(c)); printf("floor value of d: %f\n",floor(d)); return 0; }
When above program is compiled and run ,it will produce the following result
floor value of a: 12.000000
floor value of a: 12.000000
floor value of a: -13.000000
floor value of a: -13.000000
Other C programming language functions that are similar to the floor function
Ceil() function
You may like also
User defined function in C language
Arithmetic functions in C Language
String function in C language