- floor( ) function in C returns the nearest integer value which is less than or equal to the floating point argument passed to this function.
- ”math.h” header file supports floor( ) function in C language. Syntax for floor( ) function in C is given below.
double floor ( double x );
Example program for floor( ) function in C:
#include <stdio.h> #include <math.h> int main() { float i=5.1, j=5.9, k=-5.4, l=-6.9; printf("floor of %f is %f\n", i, floor(i)); printf("floor of %f is %f\n", j, floor(j)); printf("floor of %f is %f\n", k, floor(k)); printf("floor of %f is %f\n", l, floor(l)); return 0; }
Output:
floor of 5.100000 is 5.000000 floor of 5.900000 is 5.000000 floor of -5.400000 is -6.000000 floor of -6.900000 is -7.000000 |
0 comments:
Post a Comment