Floating Point Examples

X Statement Output ( _ means blank)
310.0
310.0
310.0
4.827
4.827
cout << setw(10)
<< setprecision(2)
<< x;
cout << setw(10)
<< setprecision(5)
<< x;
cout << setw(7)
<< setprecision(5)
<< x;
cout << setw(6)
<< setprecision(2)
<< x;
cout << setw(6)
<< setprecision(1)
<< x;
_ _ _ _310.00
_310.00000
310.00000
_ _4.83
_ _ _4.8


Next page
Previous page
Go to Lesson 4 index.