Presentation is loading. Please wait.

Presentation is loading. Please wait.

STRUCTURED CONTROL: BASIC CONTROL OPERATORS

Similar presentations


Presentation on theme: "STRUCTURED CONTROL: BASIC CONTROL OPERATORS"— Presentation transcript:

1 STRUCTURED CONTROL: BASIC CONTROL OPERATORS
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 1

2 Objectives Create a flowchart and pseudocode to describe a conditional program. Identify situations in which an IFTHENELSE control structure meets the design requirements. Identify situations in which a CASE control structure meets the design requirements. Identify situations in which a counter-controlled loop meets the design requirements. Identify situations in which a trailer-record loop meets the design requirements. Choose between a DOWHILE and a DOUNTIL control structure. 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 2

3 IFTHENELSE P? No Yes d c 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 3

4 Sequential IFTHENELSE
P? No Yes c Q? No Yes d 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 4

5 Nested IFTHENELSE P? Yes No c Q? Yes No e d
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 5

6 CASE Code? A ProcA B ProcB C ProcC Other ProcOther
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 6

7 Op Code Problem (Flowchart)
Start Read OP, N1, N2 OP? Result= N1+N2 Result= N1+N2 Result= N1+N2 Result= N1+N2 Result= 0 Write ‘Bad input’ Write Result, N1, N2, Op Stop 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 7

8 DOWHILE Loop e Q? 11/29/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 2 Slide 8

9 Counter-controlled Loop
Count=x Count<x Count>0 No No Yes Yes DoStuff DoStuff Count= Count+1 Count= Count-1 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 9

10 Averaging Problem (Flowchart)
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 10

11 Header Record Logic 11/29/2018© 2006 ITT Educational Services Inc.
Structured Programming: Unit 2 Slide 11

12 Averaging Problem with Header Record
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 12

13 Averaging Problem with No-Data Test
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 13

14 Reading a File - Counter DOWHILE Loop
PSEUDOCODE Count = 0 DOWHILE Count < 3 Read a record Write a record Count = Count+1 ENDDO Count=0 Count = Count + 1 Count < 3? Yes Read a record Write a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 14

15 Reading a File - Header DOWHILE Loop
PSEUDOCODE Count = 0 DOWHILE Count >0 Read a record Write a record Count = Count-1 ENDDO Count=0 Count = Count - 1 Count >0 Yes Read a record Write a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 15

16 Reading a File - Trailer DOWHILE Loop
PSEUDOCODE Read a record DOWHILE Code Not 999 Write a record ENDDO Read a record Code NOT 999? Yes Write a record Read a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 16

17 Reading a File – Auto EOF DOWHILE Loop
PSEUDOCODE Read a record DOWHILE Not EOF Write a record ENDDO Read a record Not EOF? Yes Write a record Read a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 17

18 DOUNTIL Loop Read File DoStuff Yes Done? No
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 18

19 Adding Six Numbers Using DOUNTIL (Flowchart)
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 19

20 Property -- Counter-Controlled (Flowchart)
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 20

21 Property - Header Record Logic (Structure Chart)
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 21

22 Property -- Header Record Logic -- Overall Control (Flowchart)
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 22

23 DOWHILE vs. DOUNTIL - No Initial Test
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 23

24 DOWHILE vs. DOUNTIL - Initial Test
11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 24

25 Summary In this unit, you learned:
How to design a program with conditional logic IFTHENELSE Nested IFTHENELSE Case statements How to design a program that includes loops Counter-controlled DOWHILE loop Trailer record DOWHILE loop DOUNTIL loop 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 25


Download ppt "STRUCTURED CONTROL: BASIC CONTROL OPERATORS"

Similar presentations


Ads by Google