Introduction to Loop Structures
There are 3 types of loop structures that are used within pseudocode, which are pre-condition, post-condition and count controlled loops.
This type of loop is likely the one that most are familiar with, where the loop is controlled by a condition set before the loop. It follows the structure of WHILE, ENDWHILE.
It may not execute at all, depending on the set condition. E.g:
The expression will continue evaluating until the condition becomes FALSE, at which point the loop terminates.
This type of loop depends on a condition set after the code within it has executed once, as the condition is evaluated after the code. It follows the structure of REPEAT, UNTIL.
E.g:
This type of loop depends on a counter set within its initial statement. It follows the structure of FOR, TO, NEXT.
The value of the variable used as a counter can be assigned within the FOR statement.
The default increment value for the count variable is 1, however this can be changed with the addition of an extra keyword, STEP. A negative increment can be used, and as soon as the variable reaches a value equal to or above the limit, the loop terminates.