function in C

round function in C programming language

round function in C programming language

In this tutorial, we will learn about round function in C programming language

In the C Programming Language, the round()  returns the nearest integer value of the float/double/argument passed to this function.

Declaration

Syntax

The syntax of  the round()  in C language

double round (double x);

float round(float x);

long double round(long double x);

parameters or Argument

x is the parameter or argument of this function – x is a floating point value for find round value.

Return value

when a value for x is passed, this function returns the rounded value of x

Required Header

In the C Programming Language, the required header file for the round()  is

#include <math.h>

round function in C

Example

The following example explains the usage of c language round() function

#include <stdio.h>
#include <math.h>

int main()
{    //Define temporary variable
    float i=5.2,j=6.8;
    //calculate and display round value 
    printf("round value of %f is: %f\n",i,round(i));
     printf("round value of %f is: %f\n",j,round(j));
    return 0;
}

 

When the above program is compiled and run, it will produce the following result

round value of 5.200000 is: 5.000000

round value of 6.800000 is: 7.000000

 

Similar Functions

Other C programming language functions that are  similar to the cosine function      

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

sqrt function in C language

pow function in C language

exp function in C language

log function in C language

log10 function in C language

trunc function in C language

 

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

 

ceil function in C programming language
User defined function in C programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

6 months ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

6 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

6 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

9 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

1 year ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

1 year ago