Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
23 views

Programming Structures

This document discusses programming structures for selection and repetition. It describes binary and multi-way selection using IF and CASE statements in pseudocode and decision symbols in flowcharts. It also explains guarded/pre-test and unguarded/post-test loops. Guarded loops use WHILE and FOR in pseudocode and have the condition tested at the beginning of the loop. Unguarded loops use REPEAT UNTIL in pseudocode and have the condition tested at the end so the loop always runs at least once.

Uploaded by

kwadeek
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Programming Structures

This document discusses programming structures for selection and repetition. It describes binary and multi-way selection using IF and CASE statements in pseudocode and decision symbols in flowcharts. It also explains guarded/pre-test and unguarded/post-test loops. Guarded loops use WHILE and FOR in pseudocode and have the condition tested at the beginning of the loop. Unguarded loops use REPEAT UNTIL in pseudocode and have the condition tested at the end so the loop always runs at least once.

Uploaded by

kwadeek
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like