English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and example of C library function ceil()

C Standard Library <math.h>

The ceil(x) function returns the smallest integer greater than or equal to x.

C ceil() function prototype

double ceil(double arg);

The ceil() function takes a single parameter and returns an int type value.

For example:If you pass2.3Pass to ceil(), which will return3.

The function is in<math.h>Defined in the header file.

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

To find ceil() for 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("%.2f Minimum Integer Value = %d", num, result);
   return 0;
}

Output Result

8.33 Minimum Integer Value = 9

C Standard Library <math.h>