- The three building blocks of every program
Sequence, selection and iteration control the order statements run in.
Every algorithm is built from just three constructs:
| Construct | What it does | Pseudocode |
|---|---|---|
| Sequence | run statements one after another, top to bottom | (no special keyword) |
| Selection | choose between different paths | IF…ELSE, CASE |
| Iteration | repeat statements | FOR, WHILE, REPEAT |
Sequence is automatic — statements simply run in the order written. This topic is about the other two: selection (making decisions) and iteration (looping). Both are controlled by a condition — a Boolean expression that is either TRUE or FALSE, built with the comparison operators:
| Operator | Meaning |
|---|---|
| = | equal to |
| <> | not equal to |
| < | less than |
| > | greater than |
| <= | less than or equal to |
| >= | greater than or equal to |
In Cambridge pseudocode, assignment uses the arrow ← (e.g. Total ← 0), which is different from the equality test =.
- Three constructs: sequence, selection, iteration.
- Selection = decisions (IF / CASE); iteration = loops (FOR / WHILE / REPEAT).
- Conditions are Boolean (TRUE/FALSE) using = <> < > <= >=.
- Assignment is ← ; equality test is = .