Three Building Blocks, Infinite Possibilities
Every algorithm, no matter how complex, is built from just three basic building blocks. Whether it is a simple calculator, a video game, or the software that lands a spacecraft on Mars — it all comes down to these three programming constructs:
- Sequence — Instructions executed one after another, in order
- Selection — Making a decision based on a condition (choosing a path)
- Iteration — Repeating instructions (looping)
Understanding these three constructs is fundamental to computer science. Once you can identify and use them, you can design any algorithm and write any program.
The Constructs in Everyday Life
You use these three constructs in daily life without even realising it:
Sequence in Real Life
When you make toast in the morning, you follow a sequence: get the bread, put it in the toaster, press the lever, wait, take the toast out, spread butter. The order matters — you cannot spread butter before toasting!
Selection in Real Life
When you get dressed, you make decisions: Is it raining? If yes, take an umbrella. If no, leave it at home. You are choosing a path based on a condition — that is selection.
Iteration in Real Life
When you practise penalty kicks, you repeat the same action over and over: place the ball, run up, kick, retrieve the ball, repeat. You might stop after 20 kicks (count-controlled) or keep going until you score 10 goals (condition-controlled). Both are iteration.
The Three Constructs in Detail
1. Sequence
Instructions are executed one after another, in the order they are written — like following a recipe from top to bottom. This is the simplest construct. Every program uses sequence as its foundation.
INPUT radius
SET area TO 3.14 * radius * radius
OUTPUT area
In this example, the three instructions always run in exactly this order: first the input, then the calculation, then the output. Swapping the order would produce incorrect results or errors.
2. Selection (Decisions)
The program makes a decision based on a condition. If the condition is true, one path is followed; if false, a different path is taken. This is like a fork in the road.
There are several types of selection:
IF...THEN...ELSE
INPUT age
IF age >= 18 THEN
OUTPUT "You can vote"
ELSE
OUTPUT "You cannot vote yet"
ENDIF
IF...ELSEIF...ELSE (Multiple Conditions)
INPUT score
IF score >= 70 THEN
OUTPUT "Distinction"
ELSEIF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
The program checks each condition in order. As soon as one is true, it runs that block and skips the rest. If none are true, the ELSE block runs.
3. Iteration (Loops)
A section of code is repeated either a set number of times or until a condition is met. This saves you from writing the same instructions over and over again.
There are three main types of iteration:
FOR Loop (Count-Controlled)
Repeats a set number of times. Use this when you know in advance how many times to loop.
FOR i = 1 TO 5
OUTPUT "Hello " + i
ENDFOR
This outputs “Hello 1”, “Hello 2”, “Hello 3”, “Hello 4”, “Hello 5”.
WHILE Loop (Condition-Controlled — Pre-Check)
Checks the condition before each iteration. If the condition is false at the start, the loop body may never execute.
SET count TO 1
WHILE count <= 10
OUTPUT count
SET count TO count + 1
ENDWHILE
REPEAT...UNTIL Loop (Condition-Controlled — Post-Check)
Checks the condition after each iteration. The loop body always executes at least once.
REPEAT
OUTPUT "Enter password:"
INPUT password
UNTIL password == "secret123"
OUTPUT "Access granted"
Combining the Three Constructs
Real programs combine all three constructs together. Here is an example that uses sequence, selection, and iteration:
SET total TO 0 // Sequence
SET count TO 0 // Sequence
REPEAT // Iteration
OUTPUT "Enter a mark (or -1 to finish):"
INPUT mark // Sequence
IF mark != -1 THEN // Selection
SET total TO total + mark // Sequence
SET count TO count + 1 // Sequence
ENDIF
UNTIL mark == -1 // Iteration condition
IF count > 0 THEN // Selection
SET average TO total / count // Sequence
OUTPUT "Average mark: " + average
ELSE
OUTPUT "No marks entered"
ENDIF
This algorithm repeatedly asks for marks (iteration), decides whether to add them (selection), and performs calculations in order (sequence). All three constructs working together.
Test Yourself
Click on each question to reveal the answer. Try to answer in your head first!
Answer: Sequence — instructions run in order, e.g. calculating the area of a rectangle (length * width). Selection — a decision is made, e.g. IF age >= 17 THEN “can learn to drive.” Iteration — instructions repeat, e.g. a WHILE loop that keeps asking for a password until the correct one is entered.
Answer: A WHILE loop checks its condition before each iteration, so the loop body might never execute if the condition is false from the start. A REPEAT...UNTIL loop checks its condition after each iteration, so the loop body always executes at least once. Use REPEAT...UNTIL when you need the code to run at least once (e.g. asking for user input).
Answer: Use a FOR loop when you know in advance how many times you want to repeat (e.g. “print the times table for 1 to 12”). Use a WHILE loop when the number of repetitions depends on a condition that might change during the loop (e.g. “keep asking until the user types ‘quit’”).
Answer: Nested selection is an IF statement placed inside another IF statement. For example:
IF loggedIn == TRUE THEN
IF role == "admin" THEN
OUTPUT "Welcome, admin"
ELSE
OUTPUT "Welcome, user"
ENDIF
ELSE
OUTPUT "Please log in"
ENDIF
The inner IF only runs if the outer IF condition is true. This allows multi-layered decision making.
Answer: This program uses all three constructs: Sequence — the INPUT and OUTPUT statements run in order within each iteration. Iteration — a FOR loop repeating 5 times. Selection — an IF/ELSE deciding whether each number is positive or negative.
Answer:
SET count TO 10
WHILE count >= 1
OUTPUT count
SET count TO count - 1
ENDWHILE
OUTPUT "Blast off!"
This uses sequence (OUTPUT then decrement) within iteration (WHILE loop). You could also use a FOR loop counting from 10 down to 1.
Answer: Sequence alone only allows instructions to run in a fixed order — it cannot make decisions or repeat actions. Without selection, a program cannot respond differently to different inputs. Without iteration, any repeated task would need to be written out individually, making programs enormously long and inflexible. The three constructs together give programs the flexibility to handle any situation.
Key Vocabulary
Make sure you understand and can define all of these terms.
| Term | Definition |
|---|---|
| Sequence | A programming construct where instructions are executed one after another in order. |
| Selection | A programming construct where a decision is made based on a condition (e.g. IF...THEN...ELSE). |
| Iteration | A programming construct where instructions are repeated, either a set number of times (FOR) or until a condition is met (WHILE/REPEAT...UNTIL). |
| Condition | An expression that evaluates to TRUE or FALSE, used to control selection and iteration (e.g. age >= 18, password == “correct”). |
| Count-Controlled Loop | A loop that repeats a specific number of times (FOR loop). The number of iterations is known before the loop starts. |
| Condition-Controlled Loop | A loop that repeats until a condition is met (WHILE or REPEAT...UNTIL). The number of iterations is not known in advance. |
| Nested Selection | An IF statement placed inside another IF statement, allowing multi-layered decision making. |
| Nested Iteration | A loop placed inside another loop, often used for processing two-dimensional data (e.g. rows and columns). |
Exam Tips: Programming Construct Questions
1. Identify All Three Constructs
A common exam question gives you a piece of pseudocode and asks you to identify the constructs used. Look for: statements running in order (sequence), IF/ELSE blocks (selection), and FOR/WHILE/REPEAT blocks (iteration). Make sure to give a specific example from the code for each one.
2. Choose the Right Loop Type
If the question says “repeat 10 times” → use a FOR loop. If it says “repeat until the user enters ‘quit’” → use a WHILE or REPEAT...UNTIL loop. If the action must happen at least once → prefer REPEAT...UNTIL.
3. Trace Through Carefully
When tracing code with loops and selection, go through one iteration at a time. Update each variable in your trace table before moving to the next step. Do not skip ahead or try to do multiple iterations in your head at once.
4. Watch for Off-by-One Errors
A very common mistake is getting the loop boundaries wrong. FOR i = 0 TO 4 runs 5 times (0, 1, 2, 3, 4), not 4. Always count carefully and check whether the boundary values are included.
Past Paper Questions
Try these exam-style questions, then click to reveal the mark scheme answer.
Define the term 'iteration' in programming. [1] mark
Mark scheme:
Repeating a section of code / a loop that runs a block of code multiple times (1)
Explain the difference between definite and indefinite iteration. Give an example of each. [4] marks
Mark scheme:
- Definite iteration repeats a fixed number of times / the number of repetitions is known before the loop starts (1)
- Example: a for loop / for i in range(10) (1)
- Indefinite iteration repeats until a condition is met / the number of repetitions is not known in advance (1)
- Example: a while loop / while password != correct (1)
Explain the difference between selection and iteration. [2] marks
Mark scheme:
- Selection is a decision / choosing which path to follow based on a condition (e.g. if/else) (1)
- Iteration is repeating / looping a section of code (e.g. for, while) (1)
Think About It
The three programming constructs are the grammar of programming. Just as every English sentence uses nouns, verbs, and connectives, every program uses sequence, selection, and iteration.
Think about these connections:
- Recipes use sequence (follow steps in order), selection (if the mixture is too thick, add more milk), and iteration (stir for 5 minutes)
- Board games use sequence (take turns in order), selection (if you land on a special square, follow its rule), and iteration (keep playing until someone wins)
- School timetables use sequence (lessons in order), selection (if it is Wednesday, you have PE), and iteration (the same timetable repeats each week)
Once you start seeing these patterns everywhere, you will find it much easier to design algorithms and write code. The three constructs are your toolkit — master them, and you can build anything.
Interactive Activities
- Linked List Explorer — Add, remove and search a singly linked list with visual pointer animations
- Stack Simulator — Push, pop and peek operations on a stack to understand LIFO behaviour
Interactive Games
- Program Builder — 14 drag-and-drop challenges practising sequence, selection and iteration
- Python Blocks — Visual block-based Python programming with Blockly
Further Reading
- BBC Bitesize — Edexcel GCSE Computer Science — Comprehensive coverage of programming constructs
- GCSE Topic 1: Computational Thinking & Algorithms — Full Edexcel specification coverage