Download presentation
Presentation is loading. Please wait.
Published byMitchell Reeves Modified over 9 years ago
1
The world of Constructs Control Structures
2
The three Structures Sequence Selection Loop Entry Exit
3
Sequence Control Structure The sequence control structure is used to show a single action or one action followed by another.
4
Flowchart & Pseudocode for sequence in a selection A? NoYes E D C B If A then do E Else do B do C do D
5
Selection Control Structure Conditio n FalseTrue Action 1 Action 2 One form of the selection control structure is the if-then-else, which is used to direct the program toward one course of action or another based on the evaluation of a condition.
6
Case Control Structure Condition Action 1Action 2Action 3Action 4 Condition 1Condition 2Condition 3Condition 4 The case allows for more than two alternatives when the condition is evaluated.
7
CLASS= “Freshman”? Fee = 75 Yes CLASS= “Soph”? Fee = 50 Yes No CLASS= “Junior”? Fee = 30 Yes No Fee = 10 If CLASS = “Freshman” FEE = 75 Else if CLASS = “Soph” FEE = 50 else if CLASS = “Junior” FEE=30 else FEE = 10
8
Do-While Control Structure Condition False True Action One form of the repetition control is the do-while, which tests the condition at the beginning of the loop.
9
Do-Until Control Structure Condition True False Action Another form of the repetition control structure is the do-until, which tests the condition at the end of the loop.
10
Nested Construct If-Then-Else Condition True False Action 1 Program modules often have control structures nested inside one another, each of which should have one entry point and one exit point. Do-While Condition True Action 1 False Do-While Entry point Do-While Exit point If-then-else Entry point If-then-else Exit point In this example, an if- then-else is nested inside a do-while.
11
Now it’s Your Turn Create a flowchart for number doubling program with sentinel value of zero Create a flowchart for number doubling program that uses EOF (End of File) as sentinel
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.