Answers for "c++ round number to nearest integer"

C++
2

c++ round number to whole

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double num1 = 4.8;
  	double num2 = 4.3;
  	cout << round(num1) << endl; // --> 5
  	cout << round(num2) << endl; // --> 4
}
Posted by: Guest on August-28-2021
1

c++ round number up

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double num1 = 4.8;
  	double num2 = 4.3;
  	cout << ceil(num1) << endl; // --> 5
  	cout << ceil(num2) << endl; // --> 5
}
Posted by: Guest on August-28-2021
6

nearest integer rounding in c++

cout << "Nearest value of x :" << round(x) << "n";
Posted by: Guest on May-24-2020

Code answers related to "c++ round number to nearest integer"

Browse Popular Code Answers by Language