## C – round() function

#### PrevNext

• round( ) function in C returns the nearest integer value of the float/double/long double argument passed to this function.
• If decimal value is from ”.1 to .5″, it returns integer value less than the argument. If decimal value is from “.6 to .9″, it returns the integer value greater than the argument.
• ”math.h” header file supports round( ) function in C language. Syntax for round( ) function in C is given below.

double round (double a);
float roundf (float a);
long double roundl (long double a);

……

#### Example program for round() function in C:

``` #include <stdio.h>
#include <math.h>
int main()
{
float i=5.4, j=5.6;
printf("round of  %f is  %fn", i, round(i));
printf("round of  %f is  %fn", j, round(j));
return 0;
}```

#### Output:

 round of 5.400000 is 5.000000 round of 5.600000 is 6.000000

#### Other inbuilt arithmetic functions in C:

• “math.h” and “stdlib.h” header files support all the arithmetic functions in C language. All the arithmetic functions used in C language are given below.
• Click on each function name below for detail description and example programs.
 S.no Function Description 1 abs ( ) This function returns the absolute value of an integer. The absolute value of a number is always positive. Only integer values are supported in C. 2 floor ( ) This function returns the nearest integer which is less than or equal to the argument passed to this function. 3 round.(.) This function returns the nearest integer value of the float/double/long double argument passed to this function. If decimal value is from “.1 to .5”, it returns integer value less than the argument. If decimal value is from “.6 to .9”, it returns the integer value greater than the argument. 4 ceil ( ) This function returns nearest integer value which is greater than or equal to the argument passed to this function. 5 sin ( ) This function is used to calculate sine value. 6 cos ( ) This function is used to calculate cosine. 7 cosh ( ) This function is used to calculate hyperbolic cosine. 8 exp ( ) This function is used to calculate the exponential “e” to the xth power. 9 tan ( ) This function is used to calculate tangent. 10 tanh ( ) This function is used to calculate hyperbolic tangent. 11 sinh ( ) This function is used to calculate hyperbolic sine. 12 log ( ) This function is used to calculates natural logarithm. 13 log10 ( ) This function is used to calculates base 10 logarithm. 14 sqrt ( ) This function is used to find square root of the argument passed to this function. 15 pow ( ) This is used to find the power of the given number. 16 trunc.(.) This function truncates the decimal value from floating point value and returns integer value.

.