program flow control 2

6
Program Flow Control 2

Upload: mrutherfordwest

Post on 15-Jul-2015

27 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Program flow control 2

Program Flow Control 2

Page 2: Program flow control 2

Recap

• Sequence, Selection and Iteration looked at in Program Flow Control 1

• Shapes used :

Page 3: Program flow control 2

Case

• Useful for showing a series of if..then..elsestatements where more than 2 options exist

– ie what Lego shall I buy? would have a different Lego model

• The True line always flows to the right and the False line goes to the next decision

Page 4: Program flow control 2

Case in action

Shall I buy

Castle Lego?

Shall I buy Star

Wars Lego?

Shall I buy City Lego?

Buy Castle Lego

Buy Star Wars Lego

Buy City LegoBuy no Lego

YES

NO

YES

YES

NO

NO

Page 5: Program flow control 2

Do-while

• Used for containing a process in a loop until it is completed

Page 6: Program flow control 2

Do-while in action

Buy Cake

Do you want

more?

NO

YES