Introduction
The slides cover the following topics:
C Formatted Input/Output-----------------------------------------------Next slide
OBJECTIVES
In this chapter you will learn:
9.1 Introduction
9.2 Streams
9.3 Formatting Output with printf
9.4 Printing Integers
9.5 Printing Floating-Point Numbers
9.6 Printing Strings and Characters
9.7 Other Conversion Specifiers
9.8 Printing with Field Widths and Precision
9.9 Using Flags in the printf Format Control String
9.10 Printing Literals and Escape Sequences
9.11 Reading Formatted Input with scanf
C Formatted Input/Output-----------------------------------------------Next slide
9.1 Introduction
Forgetting to enclose a format-control-string in quotation marks is a syntax error.
C Formatted Input/Output-----------------------------------------------Next slide
Good Programming Practice 9.1
Format outputs neatly for presentation to make program outputs more readable and reduce user errors.
C Formatted Input/Output-----------------------------------------------Next slide
9.4 Printing Integers
C Formatted Input/Output-----------------------------------------------Next slide
Fig. 9.1 | Integer conversion specifiers.
C Formatted Input/Output-----------------------------------------------Next slide
C Formatted Input/Output-----------------------------------------------Next slide
C Formatted Input/Output-----------------------------------------------Next slide
Common Programming Error 9.2
Printing a negative value with a conversion specifier that expects an unsigned value.
C Formatted Input/Output-----------------------------------------------Next slide
9.5 Printing Floating-Point Numbers
Fig. 9.3 | Floating-point conversion specifiers.
C Formatted Input/Output-----------------------------------------------Next slide
Error-Prevention Tip 9.1
When outputting data, be sure that the user is aware of situations in which data may be imprecise due to formatting (e.g., rounding errors from specifying precisions).
C Formatted Input/Output-----------------------------------------------Next slide
C Formatted Input/Output-----------------------------------------------Next slide
9.6 Printing Strings and Characters