C ceil()

C ceil() Prototype

double ceil( double arg );

The ceil() function takes a single argument and returns the nearest integer number.

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?

Your builder path starts here. Builders don't just know how to code, they create solutions that matter.

Escape tutorial hell and ship real projects.

Try Programiz PRO
  • Real-World Projects
  • On-Demand Learning
  • AI Mentor
  • Builder Community