In computer science or discrete structure, there are two important function are use i.e. **Floor and ceiling function** . In this tutorial we discuss definition, example using concept computer science and program of these function. Notation: ⌈x⌉ is ceiling function, ⌊x⌋ is floor function where x is variable.

Let x be a real number then **⌊x⌋** called the** floor function **of x, assigns to the real number x the largest integer that is less than or equal to x. this function rounds x down to the closest integer less than or equal to x. The floor function is also called the greatest integer function.

Let x be a real number then **⌈x⌉** called the** ceiling function **of x, assigns to the real number x the smallest integer that is greater than or equal to x. this function rounds x up to the closest integer less than or equal to x.

#### Example of Floor and ceiling function

- 5.3 Floor value
**⌊x⌋**=5 & Ceiling value**⌈x⌉**=6 - 4.5 Floor value
**⌊x⌋**=4 & Ceiling value**⌈x⌉**=5 - -4 Floor value
**⌊x⌋**=-4 & Ceiling value**⌈x⌉**=-4 - 1/2 Floor value
**⌊x⌋**=0 & Ceiling value**⌈x⌉**=1

**Prove or disprove that ⌈x+y⌉=⌈x⌉+⌈y⌉ for all real number x and y.**

solution, A counter example is supplied by x=1/2 and y=1/2. with these values we found that ⌈x+y⌉=⌈1/2+1/2⌉=⌈1⌉=1 but ⌈x+y⌉=⌈1/2+1/2⌉=1+1=2

**Another example:** Data stored on a computer or transmitted over a data network are usually represent as a string of bytes. Each byte is made up of 8 bits. How many bytes are required to encode 300 bits of data?

solution: To determine the number of bytes needed, we determine the smallest integer that is at least as large as the quotient when 300 is divided by 8. Therefore, the number of bytes required = ⌈300/8⌉=⌈37.5⌉=38 bytes.

#### Program to find Floor and ceiling function

```
#include <stdio.h>
#include <math.h>
int main()
{
float val;
float fVal,cVal;
printf("Enter a float value: ");
scanf("%f",&val);
fVal=floor(val);
cVal =ceil(val);
printf("floor value:%f \nceil value:%f\n",fVal,cVal);
return 0;
}
```