Download presentation
Presentation is loading. Please wait.
Published bySuharto Lie Modified over 6 years ago
1
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
2
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
3
Three Special Structures – Case, Do While, and Do Until (continued)
Using a case structure for multiple alternatives Programming Logic and Design, Introductory, Fourth Edition
4
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
5
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
6
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
7
Three Special Structures – Case, Do While, and Do Until (continued)
Programming Logic and Design, Introductory, Fourth Edition
8
Three Special Structures – Case, Do While, and Do Until (continued)
Programming Logic and Design, Introductory, Fourth Edition
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.