Home » Labs » Example of Ceil function in C  

Example of Ceil function in C


Filed under Labs

Here is a simple ceil example usage in C programming.

/* Example of Ceil function*/
#include <stdio.h>
#include <math.h>
 
int main ()
{
  printf ("ceil of 2.3 is %.1lf\n", ceil (2.3) );
  printf ("ceil of 3.8 is %.1lf\n", ceil (3.8) );
  printf ("ceil of -2.3 is %.1lf\n", ceil (-2.3) );
  printf ("ceil of -3.8 is %.1lf\n", ceil (-3.8) );
  return 0;
}

Output will be:
ceil of 2.3 is 3.0
ceil of 3.8 is 4.0
ceil of -2.3 is -2.0
ceil of -3.8 is -3.0

Posts you may like: