C floor() Prototype
double floor(double arg)
The floor() function takes a single argument and returns the value in type double
.
It is defined in <math.h> header file.
For example:
If 2.3 is passed to floor(), it will return 2.
In order to calculate floor() for long double or float, you can use the following prototype.
long double floorl( long double arg ); float floorf( float arg );
Example: C floor() function
#include <stdio.h>
#include <math.h>
int main()
{
double num = -8.33;
int result;
result = floor(num);
printf("Floor integer of %.2f = %d", num, result);
return 0;
}
Output
Floor integer of -8.33 = -9