Formatting for Floating-Point Numbers
The formatting capabilities in Fig. 4.10 are discussed here briefly and explained in depth in Chapter 13, Stream Input/Output: A Deeper Look. The call to setprecision in line 75 (with an argument of
2) indicates that
average should be printed with two digits of precision to the right of the decimal point (e.g., 92.37). This call is referred to as a parameterized stream manipulator (because of the
2 in parentheses). Programs that use these calls must contain the preprocessing directive (line 5)
endl is a nonparameterized stream manipulator (because it isn’t followed by a value or expression in parentheses) and does not require the
<iomanip> header. If the ...