The C floor function is a Math function that returns the closest integer value, which is less than or equal to a given number. The syntax of the math floor is as shown below.
double floor(double number);
C floor Function Example
The math floor Function allows you to find the closest integer value, which is less than or equal to a user-given number. In this program, we will find the same and display the output C Programming.
#include <stdio.h> #include <math.h> int main() { printf("\n The Floor Value of 0.75 = %.2f ", floor(0.75)); printf("\n The Floor Value of 12.25 = %.2f ", floor(12.25)); printf("\n The Floor Value of 152.50 = %.2f ", floor(152.50)); printf("\n The Floor Value of -12.36 = %.2f ", floor(-12.36)); printf("\n The Floor Value of -27.82 = %.2f ", floor(-27.32)); printf("\n The Floor Value of -90.50 = %.2f ", floor(-90.50)); return 0; }
In this program, we used the math floor function to find the closest number of the user-entered floating-point value.
#include <stdio.h>
#include <math.h>
int main()
{
float number, fValue;
printf(" Please Enter any Numeric : ");
scanf("%f", &number);
fValue = floor(number);
printf("\n The Result of %.2f = %.4f ", number, fValue);
return 0;
}
Please Enter any Numeric : 125.87
The Result of 125.87 = 125.0000