Using ceil() Function in C Programming
The ceil() function in the C language is used to return the smallest integer value that is greater than or equal to the input parameter (rounding up). This function is defined in the
double ceil(double x);
One of which, x is a float parameter that represents the value needing to be rounded up. The ceil() function returns a double value that represents the smallest integer greater than or equal to x.
For example:
#include <stdio.h>
#include <math.h>
int main() {
double x = 5.3;
double result = ceil(x);
printf("ceil(%.1f) = %.1f\n", x, result);
return 0;
}
In the example above, ceil(5.3) will return 6.0, as 6.0 is the smallest integer value that is greater than or equal to 5.3.