Professional Documents
Culture Documents
Arrays
P R O G R A M M I N G LO G I C A N D D E S I G N
FIFTH EDITION, COMPREHENSIVE
Objectives
2
Array:
Series or list of variables in computer memory
How Arrays
Occupy Computer
Memory
Each item has same
name and same data type
Example
Figure 6-3
Flowchart of decision-
making process using a
series of decisions – the
hard way
Figure 6-3
Pseudocode of decision-
making process using a
series of decisions – the
hard way (continued)
Example
Figure 6-4
Flowchart and
pseudocode of
decision-making
process – but still a
hard way
Figure 6-5
Flowchart and
pseudocode of
decision-making
process using an array
– but still a hard way
Figure 6-7
Flowchart and
pseudocode for
Dependents Report
program
Table 6-1 Declaring a 20-element array named count in several common languages
Figure 6-8 A loop that sets values for every element in an array
Figure 6-11
Program that produces
tenant letters
Figure 6-13
Flowchart for program
that verifies item
availability
Figure 6-13
Pseudocode for
program that verifies
item availability
(continued)
If the value does not match, increment the subscript and examine
the next array element
Figure 6-14
Flowchart of program
that finds an item’s
price
Figure 6-14
Pseudocode of program
that finds an item’s
price (continued)
Figure 6-16
Flowchart and
pseudocode of the loop
that finds item’s price,
exiting the loop as soon
as it is found
Figure 6-21
Program that
determines discount
rate
Figure 6-22
Determining the month
string from user’s
numeric entry
Figure 6-23
Program that uses a
selection to ensure a
valid subscript
Figure 6-24
Program that uses a
loop to ensure a valid
subscript
Compares it to a limit
Figure 6-25 Pseudocode that uses a for loop to print month names
Programming Logic and Design, Fifth Edition, Comprehensive
Using a FOR Loop to Process Arrays (continued)
45
Figure 6-26 Pseudocode that uses a more efficient for loop to print month names
Programming Logic and Design, Fifth Edition, Comprehensive
Summary
46
Search an array:
Initialize the subscript