You are here

floor function

Floor function returns the greatest integer not greater than x. For example, if the input is 2.25 then the output will be 2.00.

Declaration: double floor(double x);

C programming code for floor

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6.   double n, result;
  7.  
  8.   printf("Enter a number to round it down\n");
  9.   scanf("%lf", &n);
  10.  
  11.   result = floor(n);
  12.  
  13.   printf("Original number =  %.2lf\n", n);
  14.   printf("Number rounded down = %.2lf\n", result);
  15.  
  16.   return 0;
  17. }

Output of program:
math.h floor C program output