Post date: 09-Jan-2015 04:53:48
Iteration is also referred to as looping or repetition. Its designed to execute the same block of code again and again until a certain condition is fulfilled.
The three main looping controls are:-
- The WHILE Loop
- The REPEAT....UNTIL Loop
- The FOR Loop
The WHILE Loop
The "WHILE" loop is used if a condition has to be met before the statements within the loop are executed.
WHILE condition DO
The REPEAT....UNTIL loop
The REPEAT....UNTIL loop allows the statements within it to be executed at least once since the condition is tested at the end of the loop.
The FOR Loop
The FOR loop is used in circumstances where the execution of the chosen statements has to be repeated a predetermined number of times.
//pseudocode for 'FOR" loop that counts from the lower limit
FOR loop variable = lower limit to upper limit DO
//pseudocode for a 'FOR' loop that counts from the upper limit down to lower limit
FOR loop variable = upper limit DOWN TO lower limit DO