Home »
C solved programs »
C basic programs
C program to demonstrate example of floor() and ceil() functions
This program will demonstrate the example of floor() an ceil() function in c programming language. Both functions are library functions and declare in math.h header file.
Example of floor() and ceil() functions in c
/* C program to demonstrate example of floor and ceil functions.*/
#include <stdio.h>
#include <math.h>
int main()
{
float val;
float fVal,cVal;
printf("Enter a float value: ");
scanf("%f",&val);
fVal=floor(val);
cVal =ceil(val);
printf("floor value:%f \nceil value:%f\n",fVal,cVal);
return 0;
}
Output
Enter a float value: 123.45
floor value:123.000000
ceil value:124.000000
C Basic Programs »