C floor Function

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

double floor(double number);

C floor Function Example

The C 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;
}
C math floor Example

In this program, we used the floor function to find the closest number of the user-entered value.

#include <stdio.h>
#include <math.h>

int main()
{
    float number, floorValue;

    printf(" Please Enter any Numeric :  ");
    scanf("%f", &number);
  
    floorValue = floor(number);
  
    printf("\n The Floor of %.2f = %.4f ", number, floorValue);
  
    return 0;
}
 Please Enter any Numeric :  125.87

 The Floor of 125.87 = 125.0000