C ceil Function

The C ceil function is one of the C Math Functions, used to return the smallest integer value, which is greater than or equal to a given number or a specified expression. The syntax of the ceil in C Programming is

double ceil(double number);

C ceil Function Example

The math ceil Function allows you to find the smallest integer value, which is greater than or equal to a given number. In this program, We are going to find ceiling value and display the output.

/* CEIL in C Programming Example */

#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 ceil Function 1

C math ceil Example 2

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

/* CEIL in C Programming Example */

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

int main()
{
    float number, ceilValue;

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

 The Ceiling Value of 256.09 = 257.0000