Key Elements: Repeating Statements and a Stop Condition
CONCEPT: There are two crucial components of all iterations:
- The statements that will be repeated -- called the loop body
- A test specifying when the repetition stops – stop condition
Additionally, loops typically have at least one variable that is explicitly changed “inside” the loop -- this is called the iteration variable
When the iteration variable contains a certain value (defined by the program), then the loop stops
Some value must change at some point between consecutive iterations, or else the loop will never terminate … it is an infinite loop.