Table of Content

Ceil Function >> Round Up Value >> Math.h >> Header File in C



Ceil Function :

  1. Ceil() is also Called as “Round Up
  2. floorl Function Evaluates “floorl finds the Smallest (long double) integer not Less than x.”
  3. Ceil() Returns the Smallest integral value that is not Less than x.
  4. Suppose num = 12.1 then ceil(num) Returns 13
  5. Header File : Math.h

Syntax :

double ceil (double x);
float ceil (float x);
long double ceil (long double x);

Live Example :

/* floor example */
#include<stdio.h>
#include<math.h>

int main ()
{
printf (“ceil of 4.5 is %fn”, ceil(4.5));
printf (“ceil of 6.1 is %fn”, ceil(6.1));
printf (“ceil of -2.3 is %fn”, ceil(-2.3));
printf (“ceil of -3.8 is %fn”, ceil(-3.8));
return 0;
}

Output :

floor of  4.5 is 5
floor of  6.1 is 7
floor of -2.3 is -2
floor of -3.8 is -3

Negative Parameter ???

  1. As we Move Towards Positive Direction , we can conclude that -
5 > 4 > 3 > 2 > 1
  1. So ceil(3.2) Returns ==> 4
  2. As we Move Towards Negative Direction , we can conclude that -
-1 > -2 > -3 > -4 > -5
  1. So ceil(-3.2) Returns ==> -3