Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using the Priming Read Priming read (or priming input):

Similar presentations


Presentation on theme: "Using the Priming Read Priming read (or priming input):"— Presentation transcript:

1 Using the Priming Read Priming read (or priming input):
Reads the first input data record Outside the loop that reads the rest of the records Helps keep the program structured Analyze a flowchart for structure one step at a time Watch for unstructured loops that do not follow this order: First ask a question Take action based on the answer Return to ask the question again Programming Logic and Design, Introductory, Fourth Edition

2 Using the Priming Read (continued)
Unstructured loop: Programming Logic and Design, Introductory, Fourth Edition

3 Using the Priming Read (continued)
Structured but nonfunctional loop Programming Logic and Design, Introductory, Fourth Edition

4 Using the Priming Read (continued)
Corrrect Programming Logic and Design, Introductory, Fourth Edition

5 Using the Priming Read (continued)
Functional and structured loop Programming Logic and Design, Introductory, Fourth Edition

6 Using the Priming Read (continued)
Priming read sets up the process so the loop can be structured To analyze a flowchart’s structure, try writing pseudocode for it Programming Logic and Design, Introductory, Fourth Edition

7 Using the Priming Read (continued)
What is wrong with this design? Programming Logic and Design, Introductory, Fourth Edition

8 Understanding the Reasons for Structure
Advantages of structure: Provides clarity Professionalism Efficiency Ease of maintenance Supports modularity Programming Logic and Design, Introductory, Fourth Edition

9 Understanding the Reasons for Structure (continued)
Programming Logic and Design, Introductory, Fourth Edition

10 Recognizing Structure (continued)
Next, pull up the flowline on the right side of B Programming Logic and Design, Introductory, Fourth Edition

11 Recognizing Structure (continued)
Now pull up the flowline on the right side of D Programming Logic and Design, Introductory, Fourth Edition

12 Recognizing Structure (continued)
Bring together the loose ends of D and of B Programming Logic and Design, Introductory, Fourth Edition

13 Three Special Structures – Case, Do While, and Do Until
Many languages allow three additional structures: case structure do-while structure do-until structure Case Structure: Decisions with more than two alternatives Tests a variable against a series of values and takes action based on a match Nested if-then-else statements will do what a case structure does Programming Logic and Design, Introductory, Fourth Edition

14 Three Special Structures – Case, Do While, and Do Until (continued)
Using nested if-then-else for multiple alternatives Programming Logic and Design, Introductory, Fourth Edition

15 Three Special Structures – Case, Do While, and Do Until (continued)
Using a case structure for multiple alternatives Programming Logic and Design, Introductory, Fourth Edition

16 Three Special Structures – Case, Do While, and Do Until (continued)
do-while and do-until loops Question is asked at the end of the loop structure Ensures that the loop statements are always used at least once Programming Logic and Design, Introductory, Fourth Edition

17 Three Special Structures – Case, Do While, and Do Until (continued)
do-while loop executes as long as the question’s answer is Yes or True Test checked at beginning May not be executed do-until loop executes as long as the question’s answer is No or False (until it becomes Yes or True) Test checked at end of loop Will always execute loop at least once Programming Logic and Design, Introductory, Fourth Edition

18 Three Special Structures – Case, Do While, and Do Until (continued)
while loop with question at beginning is called a pretest loop do-until with question at end are called posttest loops Programming Logic and Design, Introductory, Fourth Edition

19 Three Special Structures – Case, Do While, and Do Until (continued)
Programming Logic and Design, Introductory, Fourth Edition

20 Three Special Structures – Case, Do While, and Do Until (continued)
Programming Logic and Design, Introductory, Fourth Edition


Download ppt "Using the Priming Read Priming read (or priming input):"

Similar presentations


Ads by Google