- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - floor()
Description
The C library function double floor(double x) returns the largest integer value less than or equal to x.
Declaration
Following is the declaration for floor() function.
double floor(double x)
Parameters
x − This is the floating point value.
Return Value
This function returns the largest integral value not greater than x.
Example
The following example shows the usage of floor() function.
#include <stdio.h> #include <math.h> int main () { float val1, val2, val3, val4; val1 = 1.6; val2 = 1.2; val3 = 2.8; val4 = 2.3; printf("Value1 = %.1lf\n", floor(val1)); printf("Value2 = %.1lf\n", floor(val2)); printf("Value3 = %.1lf\n", floor(val3)); printf("Value4 = %.1lf\n", floor(val4)); return(0); }
Let us compile and run the above program that will produce the following result −
Value1 = 1.0 Value2 = 1.0 Value3 = 2.0 Value4 = 2.0
math_h.htm
Advertisements
To Continue Learning Please Login
Login with Google