Header file:
math.h
Synopsis:
double ceil(double x);
Description:
Returns the ceiling of x. (If x is 4.5, value 5 will be returned).
ceil function C example:
#include<stdio.h>
#include<math.h>
int main() {
double input, res;
printf("Enter your input:");
scanf("%lf", &input);
res = ceil(input);
printf("ceil(%lf):%lf\n", input, res);
return 0;
}
#include<math.h>
int main() {
double input, res;
printf("Enter your input:");
scanf("%lf", &input);
res = ceil(input);
printf("ceil(%lf):%lf\n", input, res);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/math$ gcc ceil.c -lm
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:4.5
ceil(4.500000):5.000000
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:4.5
ceil(4.500000):5.000000
No comments:
Post a Comment