Programming Structures
Selection
Binary Selection
The binary selection structure is represented by IF statements
in pseudocode. In a flowchart, the decision symbol is used
with the TRUE path branching to the right and the FALSE path
branching to the left.
Multi-way Selection
The multi-way selection structure is represented in
pseudocode by the CASE statement. In a flowchart, a decision
symbol is used with the options branching from a single line attached to the bottom of
the diamond symbol.
Repetition
Guarded / Pre-test Loops
Guarded loops are represented by WHILE or FOR in pseudocode. In flowcharts, a decision
symbol is used. The TRUE line flows down from the bottom of the diamond symbol,
looping back up on the left side. An arrow should be used to show that the flow of the
program is going up (against the norm). The FALSE line connects to the right of the
diamond and runs down the right side of the page before returning to a central point.
The condition (decision / question) is tested at the beginning of the loop. This means
that the code within the loop may not run at all.
Unguarded / Post-test Loops
Unguarded loops are
represented in pseudocode
using REPEAT... UNTIL statements. In a flowchart, the
FALSE line (which continues the loop – note: this is
opposite to the pre-test loop) flows from the left point of
the diamond and up the left of the page. This line then
joins the central line above the loop processes. The
TRUE line (ie: the loop exit) flows from the bottom of
the diamond. The condition (decision / question) is
tested at the end of the loop. This means that the loop
always runs at least once.