Download presentation
Presentation is loading. Please wait.
1
Topics discussed in this section:
2-7 Input/Output Although our programs have implicitly shown how to print messages, we have not formally discussed how we use C facilities to input and output data. We devote two chapters, Chapter 7 and 13, to fully explain the C input/output facilities and how to use them. In this section, we describe simple input and output formatting. Topics discussed in this section: Streams Formatting Input/Output Computer Science: A Structured Programming Approach Using C
2
for a text stream; a monitor is a destination
Note A terminal keyboard and monitor can be associated only with a text stream. A keyboard is a source for a text stream; a monitor is a destination for a text stream. Computer Science: A Structured Programming Approach Using C
3
FIGURE 2-15 Stream Physical Devices
Computer Science: A Structured Programming Approach Using C
4
FIGURE 2-16 Output Formatting Concept
Computer Science: A Structured Programming Approach Using C
5
FIGURE 2-17 Output Stream Formatting Example
Computer Science: A Structured Programming Approach Using C
6
FIGURE 2-18 Conversion Specification
Computer Science: A Structured Programming Approach Using C
7
Format Codes for Output
Table 2-10 Format Codes for Output Computer Science: A Structured Programming Approach Using C
8
Flag Formatting Options
Table 2-11 Flag Formatting Options Computer Science: A Structured Programming Approach Using C
9
FIGURE 2-19 Formatting Text from an Input Stream
Computer Science: A Structured Programming Approach Using C
10
FIGURE 2-20 Input Stream Formatting Example
Computer Science: A Structured Programming Approach Using C
11
FIGURE 2-21 Conversion Specification
Computer Science: A Structured Programming Approach Using C
12
scanf requires variable addresses in the address list.
Note scanf requires variable addresses in the address list. Computer Science: A Structured Programming Approach Using C
13
Table 2-12 scanf Rules Computer Science: A Structured Programming Approach Using C
14
2-8 Programming Examples
In this section, we show some programming example to emphasize the ideas and concepts we have discussed about input/output. Computer Science: A Structured Programming Approach Using C
15
A Program That Prints “Nothing!”
Computer Science: A Structured Programming Approach Using C
16
Demonstrate Printing Boolean Constants
PROGRAM 2-5 Demonstrate Printing Boolean Constants Computer Science: A Structured Programming Approach Using C
17
Demonstrate Printing Boolean Constants (continued)
PROGRAM 2-5 Demonstrate Printing Boolean Constants (continued) Computer Science: A Structured Programming Approach Using C
18
Print Value of Selected Characters
PROGRAM 2-6 Print Value of Selected Characters Computer Science: A Structured Programming Approach Using C
19
Print Value of Selected Characters (continued)
PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C
20
Print Value of Selected Characters (continued)
PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C
21
Print Value of Selected Characters (continued)
PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C
22
Calculate a Circle’s Area and Circumference
PROGRAM 2-7 Calculate a Circle’s Area and Circumference Computer Science: A Structured Programming Approach Using C
23
Calculate a Circle’s Area and Circumference (continued)
PROGRAM 2-7 Calculate a Circle’s Area and Circumference (continued) Computer Science: A Structured Programming Approach Using C
24
FIGURE 2-22 Output Specifications for Inventory Report
Computer Science: A Structured Programming Approach Using C
25
A Sample Inventory Report
PROGRAM 2-8 A Sample Inventory Report Computer Science: A Structured Programming Approach Using C
26
A Sample Inventory Report (continued)
PROGRAM 2-8 A Sample Inventory Report (continued) Computer Science: A Structured Programming Approach Using C
27
FIGURE 2-23 Complex Number Attributes
Computer Science: A Structured Programming Approach Using C
28
Print Complex Number Attributes
PROGRAM 2-9 Print Complex Number Attributes Computer Science: A Structured Programming Approach Using C
29
Print Complex Number Attributes (continued)
PROGRAM 2-9 Print Complex Number Attributes (continued) Computer Science: A Structured Programming Approach Using C
30
Complex Number Arithmetic
PROGRAM 2-10 Complex Number Arithmetic Computer Science: A Structured Programming Approach Using C
31
Complex Number Arithmetic (continued)
PROGRAM 2-10 Complex Number Arithmetic (continued) Computer Science: A Structured Programming Approach Using C
32
Complex Number Arithmetic (continued)
PROGRAM 2-10 Complex Number Arithmetic (continued) Computer Science: A Structured Programming Approach Using C
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.