 ceil in c programming

## What is ceil in c programming?

ceil in c is library function which is used to find out integer value greater than or equal to the given number.

This function is defined in math.h header file.

### Prototype

``````double ceil(double m);
float ceilf(float y);
long double ceill(long double y);``````

### Parameters

ceil function takes floating point number as input parameter.

### Return value

ceil function returns integer value greater than or equal to the given number.

## Example program for ceil in c

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

int main()
{
float val=1.6;
printf("ceil value is %lf \n",ceil(val));
return 0;
}``````

``gcc file_name.c -lm``

### Code explanantion

The ceil value of a given number is found by calling ceil function and the result is printed onto the console.

ceil() Man page

## Difference between ceil and floor

ceil in c is used to find out the nearest integer value which is greater than or equal to the given number. The floor in c is used to find out the nearest integer value which is less than or equal to the given value.

Prototypes are as follows

``````double ceil(double y);
float ceilf(float y);
long double ceill(long double y);

double floor(double y);``````

## Difference between ceil and abs in c

ceil in c is used to find out the nearest integer value which is greater than or equal to the given number. abs in c is used to find out the absolute value of a given number.

ceil is included in math.h header file. abs is included in stdlib.h header file.

Prototypes are as follows

``````double ceil(double y);
float ceilf(float y);
long double ceill(long double y);

int abs(int m);``````