Home >>C Math Functions >C math ceil() function

C math ceil() function

C math ceil() function

The C math ceil() function is used to return the smallest integer value greater than or equal to the given argument x. It takes a single argument and returns a value of type int. This function is defined in <math.h> header file.

Syntax:
double ceil(double x)

Parameter Values

x− It is the floating point value.

Here is an example of ceil() function:

#include <stdio.h>
#include <math.h>
int main () 
{
float val;
val = 1.6;
printf ("value = %.1lf\n", ceil(val));
return(0);
}

Output:
value = 2.0
Example-2

#include <stdio.h>
#include <math.h>
int main () 
{
float val;
val = 9.4593;
printf ("value = %.1lf\n", ceil(val));
return(0);
}

Output:
value = 10.0

No Sidebar ads