CST 8110 - How to Construct a Loop

Initialization

What variables need starting values, once, before we begin the loop?

Variables used in the control_expression?

Variables used in the loop body?

Condition (control_expression)

Determine the terminating condition that makes the logical control_expression false and thus tells when to stop looping.

Increment / decrement

What variable or variables must change value during the looping, so that the terminating condition eventually happens?

Usually done at the end of the loop body.

Body

The statements that are repeated in the loop.