round double to int cpp code example
Example 1: c++ round to int
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x = 15;
double result;
result = round(x);
cout << "round(" << x << ") = " << result << endl;
return 0;
}
Example 2: double to int c++
double x = 5.4;
int y = (int) x;