Starting Out With Programming Logic & Design - Chapter5 - Repetition Structures
Starting Out With Programming Logic & Design - Chapter5 - Repetition Structures
Repetition Structures
Second Edition
by Tony Gaddis
Chapter Topics
5.1 Introduction to Repetition Structures
5.2 Condition-Controlled Loops: While, DoWhile, and Do-Until
5.3 Count-Controlled Loops and the For
Statement
5.4 Calculating a Running Total
5.5 Sentinels
5.6 Nested Loops
Copyright 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
1-2
1-3
Do-While Loop
Do some task, while condition is true
Do-Until Loop
Do some task, while a condition is false (or until
its true)
1-4
1-5
1-6
1-7
1-8
1-9
1-10
1-11
1-12
5.5 Sentinels
A sentinel is a special value that marks the end of
a list of values, used as stop values for loops
How it can be done
Ask the user at the end of each loop iteration, if
there is another value to process
Ask the user at the beginning of the loop, how
many times the loop should process
1-13
1-14