floor()




The floor function returns the largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer).
 
Sample Program:

#include<stdio.h> 
#include<math.h> 
 
main() 
 
double number, result; 
printf("Enter a number to round it down "); 
 
scanf("%lf",&number); 
result = floor(number); 
printf("Original number = %lf\n", number); 
printf("Number rounded down = %lf", result); 
 
return 0; 
 
}

Output:

Enter a number to round it down -2.3
Original number = -2.300000
Number rounded down = -3.000000

Post a Comment

0 Comments