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

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

int main()
{
  double n, result;

  printf("Enter a number to round it down\n");
  scanf("%lf", &n);

  result = floor(n);

  printf("Original number =  %.2lf\n", n);
  printf("Number rounded down = %.2lf\n", result);

  return 0;
}

Output of program:
math.h floor C program output