APCO 1P93 Lecture Notes - Lecture 8: Duplicate Code

76 views4 pages

Document Summary

A repetition structure causes a statement or set of statements to execute repeatedly. While loop: while a condition is true, do some task. Do-while loop: do some task, while condition is true. Do-until loop: do some task, while a condition is false (or until it"s true) With all loops, be careful not to create infinite loops always provide a way to break out. Figure 5-1: the logic of a while loop. To run a program multiple times, modules can be put within a loop. Figure 5-8 flowchart for the main module in. Loop iterates until a condition is true, but not all languages support this type of loop. Figure 5-10: the logic of a do-until loop. A count-controlled loop iterates a specific number of times. A for loop is best used for this situation. For countervariable = startingvalue to maxvalue statement statement. There is an initialization, test, and increment expression that controls the loop.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents