DO UNTIL Tools for Structured and Object-Oriented Design
DO UNTIL
Tools for Structured and Object-Oriented Design
Objectives
• Indentify, and use in program design, the DO UNTIL control Structure
• Distinguish between the logic of a DOWHILE pattern and the logic of a DOUNTIL pattern.
Using the Do Until Loop
• When you use either a while or a for loop, the body of the loop may never execute
• When you want to ensure that a loop’s body executes at least one time, you can use a do until loop
• In a do until loop, the loop control variable is evaluated after the loop body executes
• Therefore, the body always executes at least one time
do until Loop for Producing One Extra Label
Printing One Label, Then Printing Enough to Cover Production
Recognizing the Characteristics Shared by All Loops• All structured loops share these characteristics:
– The loop-controlling question provides either entry to or exit from the repeating structure
– The loop-controlling questions provide the only entry to or exit from the repeating structure
• You should also notice the difference between unstructured loops and the structured do until and while loops
DO UNTIL Example
DO UNTIL Example
DO UNTIL ExamplePseudocode
DO UNTIL Example
DO UNTIL Example
DO UNTIL Examples
DOWHILE vs. DOUNTIL
DOWHILE vs. DOUNTIL