I can use both to do the same thing in my code, so is there any benefit of using one or the other?
double myvariable(4.2432);
cout.precision(2);
cout << myvariable << " using cout.precision \n";
cout << setprecision(2) << myvariable << " using setprecision \n";
Both output 4.2
Last edited on