C ceil()

C ceil() Prototype

double ceil( double arg );

The ceil() function takes a single argument and returns a value of type int.

For example: If 2.3 is passed to ceil(), it will return 3.


The function is defined in <math.h> header file.

long double ceill( long double arg );
float ceilf( float arg );

In order to find the ceil() of long double or float, you can use the above prototype.


Example: C ceil() function

#include <stdio.h>
#include <math.h>

int main()
{
   double num = 8.33;
   int result;

   result = ceil(num);
   printf("Ceiling integer of %.2f = %d", num, result);

   return 0;
}

Output

Ceiling integer of 8.33 = 9
Did you find this article helpful?