There are three types of program construct:
- iteration (repetition).
- for loop;
- repeat loop;
- while loop.
Each type of loop has its own characteristics:
- A for loop is used when the number of iterations is known in advance.
- A repeat loop carries on repeating until some condition is satisfied, so must run at least once.
- A while loop tests a condition at the start of a loop and only continues while the condition is true. If the condition is false at the outset then the rest of the code in the loop will not be executed at all.
Now, we consider each of these in turn: