Pages

Saturday 5 July 2014

C – ceil() function

  • ceil( ) function in C returns nearest integer value which is greater than or equal to the argument passed to this function.
  • ”math.h” header file supports ceil( ) function in C language. Syntax for ceil( ) function in C is given below.
double ceil (double x);

Example program for ceil() function in C:

 #include <stdio.h>
#include <math.h>
 int main()
{
       float i=5.4, j=5.6;
       printf("ceil of  %f is  %f\n", i, ceil(i));
       printf("ceil of  %f is  %f\n", j, ceil(j));
       return 0;
}

Output:


ceil of 5.400000 is 6.000000
ceil of 5.600000 is 6.000000

3 comments: