Ceil Function >> Round Up Value >> Math.h >> Header File in C
Ceil Function :
- Ceil() is also Called as “Round Up“
- floorl Function Evaluates “floorl finds the Smallest (long double) integer not Less than x.”
- Ceil() Returns the Smallest integral value that is not Less than x.
- Suppose num = 12.1 then ceil(num) Returns 13
- 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 ???
- As we Move Towards Positive Direction , we can conclude that -
5 > 4 > 3 > 2 > 1
- So ceil(3.2) Returns ==> 4
- As we Move Towards Negative Direction , we can conclude that -
-1 > -2 > -3 > -4 > -5
- So ceil(-3.2) Returns ==> -3