## What is round in c programming?

round in c is a math function which is used to find out nearest value of a given float/double/long double number.

This function is defined in math.h header file.

### Prototype

```
double round(double x);
float roundf(float x);
long double roundl(long double x);
```

### Parameter

round function takes floating point number as input parameter.

### Return value

round in c returns nearest value of a given float/double/long double number.

## Example program for round in c

```
#include<stdio.h>
#include<math.h>
int main()
{
float x=7.8;
printf("Nearest value is %f \n",round(x));
return 0;
}
```

While using gcc use below command to add math header.

`gcc file_name.c -lm`

### Code explanation

The given number is rounded off to the nearest value by passing it to the round function. The result is being printed onto the console.

## Difference between round and abs in c

The round function is used to find out the nearest float/double/long double type value of a given number. abs in c is used to find out the absolute value of a given number.

round function is included in math.h header file. abs is included in stdlib.h header file.

round function works on floating type number. abs works on integer type number.

Prototypes are as follows

```
double round(double x);
float roundf (float x);
long double roundl (long double x);
int abs(int m);
```

round( ) | abs( ) |

Used to find out nearest float/double/long double type value of given number. | Used to find out absolute value of given number. |

`double round(double x);` | `int abs(int m);` |

## Difference between round and floor in c

round in c is used to find out the nearest float/double/long double type value of a given number. The floor in c is used to find out the nearest integer which is less than or equal to the given value.

Prototypes are as follows

```
double round(double x);
float roundf (float x);
long double roundl (long double x);
double floor(double y);
```

round( ) | floor( ) |

Used to find out nearest float/double/long double type value of given number. | Used to find out nearest integer which is less than or equal to given number. |

`double round(double x);` | double floor(double y); |

## Difference between round and ceil in c

the round function is used to find out the nearest float/double/long double type value of a given number. ceil in c is used to find out the nearest integer value which is greater than or equal to the given number.

Prototypes are as follows

```
double round(double x);
float roundf (float x);
long double roundl (long double x);
double ceil(double y);
```

round( ) | ceil( ) |

Used to find out nearest float/double/long double type value of given number. | Used to find out nearest integer value which is greater than or equal to given number. |

`double round(double x);` | `double ceil(double y);` |

## People also ask for

### What is round in c?

round in c is a math function that is used to find out the nearest value of a given float/double/long double number.

### Does c round up or down?

It rounds nearest to zero. It is defined in math.h header file.