Looping

 

I.  The While Statement

II.  Phases of Loop Execution

III.  Loops Using The While Statement

A.  Count-Controlled Loops

B.  Event-Controlled Loops

1.  Sentinel-Controlled Loops

2.  End-Of-File Controlled Loops

3.  Flag Controlled Loops

C.  Looping Subtasks

1.  Counting

2.  Summing

3.  Keeping Track of a Previous Value

D.  Theoretical Foundations: Finite State Machines

IV.  How to Design Loops

A.  Designing the Flow of Control

1.  Count-Controlled Loops

2.  Sentinel-Controlled Loops

3.  End-Of-File Controlled Loops

4.  Flag Controlled Loops

B.  Designing the Process Within the Loop

C.  The Loop Exit

V.  Nested Logic

A.  Designing Nested Loops

B.  Theoretical Foundations: The Magnitude of Work

VI.  Testing and Debugging

A.  The Loop Invariant

B.  Loop Testing Strategy

C.  Testing and Debugging Hints

VII.  Summary