Introduction
In any programming language, functions serve as the building blocks of code. They allow us to perform specific tasks with a certain set of inputs. Among the rich repertoire of functions in the C library, one of the most commonly used functions is the round() function. This function is used to round off floating-point numbers to the nearest integer.

In this article, we will delve into the workings of the round() function in C, demonstrating its use with a simple code snippet, and answering some of the frequently asked questions about it.
What is round() Function in C?
The round() function is a mathematical function, it's a part of the <math.h> in C library. round() Function in C round a floating-point number to its nearest integral value. If the fractional part of the number is 0.5 or above, the function rounds it up to the next integer; otherwise, it rounds it down.
To use the round() function, we first need to include the math.h library in our code:
#include <math.h>
//Here's a simple use case of the round() function:
#include <stdio.h>
#include <math.h>
int main() {
double num = 5.7;
double result;
result = round(num);
printf("Rounded value of %.1f is %.1f\n", num, result);
return 0;
}
Output

In the above program, the round() function rounds the number 5.7 up to the nearest whole number, which is 6.0.
Also read - Bit stuffing program in c