Something like as follows. Hope that its understandable.
Output:https://www.ideone.com/EnP40j
#include <iostream>
#include <iomanip>
#include <cmath>
int main()
{
float num1 = 95.345f;
float num2 = 95.344f;
num1 = roundf(num1 * 100) / 100; //rounding two decimals
num2 = roundf(num2 * 100) / 100; //rounding two decimals
std::cout << std::setprecision(2) << std::fixed
<< num1 << " " << num2 << std::endl;
return 0;
}
2
solved how to round off float after two place decimal in c or c++