C Program to Round-off a Given Floating Point Value

C Program to Round-off a Given Floating Point Value. The round( ) method in C returns the integer value that is closest to the float/double/long double input supplied to it. It returns an integer value less than the parameter if the decimal value is between “1 and.5′′.

It returns the integer value bigger than the parameter if the decimal value is between “.6 and.9′′.In C, the round( ) function is supported by the “math.h” header file. In C, the round( ) function has the following syntax.

#include <stdio.h>
#include <math.h>
int main()
float i=2.4, j=3.6;
printf("round of %f is %f\n", i, round(i));
printf("round of %f is %f\n", j, round(j));
return 0;



round of 2.400000 is 2.000000
round of 3.600000 is 4.000000

Header File in C Program

A header file is an h-extensioned file that contains C function declarations and macro definitions that can be shared by multiple source files. A header file’s primary function is to propagate declarations to code files. Header files allow us to store declarations in one place and then import them wherever they are needed.

In multi-file programs, this can save a lot of typing. Header files are simply files in which you can declare your own functions that can be used in your main program or while writing large C programs. Using this program method we can execute the Round Function in C.

Float Data Type in C Program

A float is a data type in computer science that is composed of a number that is not an integer because it includes a fraction represented in decimal format. Some argue that the float data type is used in computer programming when more precision than integers can provide is required.

Return Statement to Execute Round Function in C

A return statement in computer programming causes execution to exit the current subroutine and resume at the point in the code immediately after the instruction that called the subroutine, known as its return address.