C ceil Function

The C ceil function is one of the Math Functions that returns the smallest integer value, greater than or equal to a given number or a specified expression. The syntax of the math ceil function is

double ceil(double number);

C ceil Function Example

This math Function allows you to find the smallest integer value greater than or equal to a given number. In this program, we will find the ceiling value and display the output.

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

int main()
{
    printf("\n The Ceil Value of 0.75    = %.2f ", ceil(0.75));
    printf("\n The Ceil Value of 12.25   = %.2f ", ceil(12.25));    
    printf("\n The Ceil Value of 152.50  = %.2f ", ceil(152.50));
    
    printf("\n The Ceil Value of -12.36  = %.2f ", ceil(-12.36)); 
    printf("\n The Ceil Value of -27.82  = %.2f ", ceil(-27.32));  
    printf("\n The Ceil Value of -90.50  = %.2f ", ceil(-90.50));
  
    return 0;
}
C math ceil or ceiling Function Example

math ceil Example 2

In this C Programming example, we allow the users to enter their own value. Next, the program uses the ceil function to find the closest numbers.

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

int main()
{
    float number, ceilValue;

    printf(" Please Enter any Numeric :  ");
    scanf("%f", &number);
  
    ceilValue = ceil(number);
  
    printf("\n The Ceiling of %.2f = %.4f ", number, ceilValue);
  
    return 0;
}
 Please Enter any Numeric :  256.09

 The Ceiling of 256.09 = 257.0000