In C++, the round() function is defined in the <cmath> or <math.h> header file and is used to round a floating-point value to the nearest integer. If the fractional part is 0.5 or greater, the value is rounded away from zero.
The round() function supports float, double, and long double values.
For example
It has the following syntax.
x : The value which can be either float or double.
It returns the rounded value of x. The return type of the value can be float, double or long double.
Here, we are going to discuss several examples to demonstrate the List round() Function Function.
This example demonstrates how the round() function rounds a positive floating-point value to the nearest integer.
Output:
The value of x is : 8.3 Rounded value of x is : 8
This example demonstrates how the round() function behaves when the input value is negative.
Output:
The value of x is : -9.9 Rounded value of x is : -10
This example demonstrates how the round() function behaves when the input value is already an integer. In this case, the same value is returned.
Output:
The value of x is : 12 Rounded value of x is : 12
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India