Number Format Homework Sheet
What is printed by the following C++ program fragments?
a) int num2;
num2 = 1234;
cout
<< '|' << setw(5) << num2 <<
'|' << endl;
b) float money;
money = 23.99;
cout
<< setprecision(4)
<< fixed
<< showpoint;
cout
<< money << endl;
cout
<< setprecision(2);
cout
<< money << endl;
c) float mostuff;
mostuff
= 1111123.99;
cout
<< setprecision(5)
<< showpoint;
cout
<< mostuff << endl;
d) cout
<< .004568965 << endl;
cout
<< setprecision(3) << .004568965 <<
endl;
cout
<< scientific << .004568965 << endl;
e) cout << setprecision(3);
cout
<< scientific;
cout
<< 123 << endl;
cout
<< 123.0 << endl;
cout
<< 34.5 << endl;
cout
<< .000678 << endl;
cout
<< .24 << endl;
cout
<< 12.4 << endl;