C math - ceil() Function
The C math ceil() function is used to return the next highest integer value by rounding up the specified number, if necessary. In other words, it rounds the fraction UP of the given number.
Syntax
double ceil(double x); float ceilf(float x); long double ceill(long double x);
Parameters
x |
Specify a number. |
Return Value
Returns the next highest integer value by rounding UP the specified number, if necessary.
Example:
In the below example, ceil() function is used to round the fraction UP of the specified number.
#include <stdio.h> #include <math.h> int main (){ printf("%lf\n", ceil(10.5)); printf("%lf\n", ceil(-10.5)); printf("%lf\n", ceil(0.5)); printf("%lf\n", ceil(-0.5)); return 0; }
The output of the above code will be:
11.000000 -10.000000 1.000000 -0.000000
❮ C <math.h> Library