Chap3 - Chapter 3 1 Outline Formatting Numbers for Program Output Using Mathematical Library Functions Program Input Using the cin Object Symbolic

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Outline ± Formatting Numbers for Program Output ± Using Mathematical Library Functions ± Program Input Using the cin Object ± Symbolic Constants
Background image of page 2
3 Formatting Numbers for Program Output ± Proper output formatting contributes to ease of use and user satisfaction ± cout with stream manipulators can control output formatting
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Formatting Numbers for Program Output (continued) Table 3.1 Commonly Used Stream Manipulators
Background image of page 4
5 Formatting Numbers for Program Output (continued) Table 3.1 Commonly Used Stream Manipulators (continued)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Formatting Numbers for Program Output (continued)
Background image of page 6
7 Formatting Numbers for Program Output (continued) ± iomanip header file must be included to use manipulators requiring arguments ± The field width manipulator setw () only affect the number immediately followed ± Other manipulators remain in effect until they are changed
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Formatting Numbers for Program Output (continued) ± Formatting floating-point numbers requires three field-width manipulators to ± Set the total width of the display using setw ± Force a decimal place using fixed ± Set the number of significant digits after the decimal point using setprecision Example: produces this output:
Background image of page 8
9 Formatting Numbers for Program Output (continued) ± If the field width is too small, cout ignores the setw manipulator setting and allocates enough space for printing ± setprecision : sets the number of digits after the decimal point if a decimal point has been explicitly forced; otherwise, it sets the total number of displayed digits ± If setprecision setting is too small, the fractional part of the value is rounded to the specified number of
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2009 for the course CSC 101 taught by Professor Betancourt during the Spring '09 term at CUNY City.

Page1 / 34

Chap3 - Chapter 3 1 Outline Formatting Numbers for Program Output Using Mathematical Library Functions Program Input Using the cin Object Symbolic

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online