I am new in C++. I am trying to divide "1" and "2". I want to round the result to thousandths (3 decimals) using setprecision. I have tried to do that, but unsuccessfully. What should I change in my code so that I get the result that I want?
My code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float a;
float b;
cout << "1: ";
cin >> a;
cout << "2: ";
cin >> b;
float result = a/b;
cout << a << " / " << b << " = " << result << setprecision(3) << endl;
}