Combining sequence, selection and iteration in one algorithm
Set counters to 0 first (sequence), loop to read input (iteration), use IF inside the loop to pick values to count or total (selection), then OUTPUT the result after the loop.
Understanding Combining sequence, selection and iteration in one algorithm in IGCSE Computer Science Paper 2
What it does: A FOR loop repeats the INPUT 30 times, which is the iteration part of the algorithm. The OUTPUT comes after NEXT, so it runs once when all the data has been processed rather than on every repeat. Selection inside the loop picks only the values you want to count. Without the IF, every mark would be counted. Total must be set to 0 before the loop. If you set it afterwards, the total is wiped out before it is output. MOD gives the remainder, so Number MOD 2 = 0 means the number is even. DIV gives the whole-number part of a division, which is not what we need here.
Common mistakes: Cambridge pseudocode reads a value with INPUT, not READ. The line should be INPUT Price, so each pass of the loop reads one price. An IF statement needs THEN after its condition. The line should be IF Temp > 30 THEN, so the selection decides which temperatures are added to Total.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 389–398) and word search (Modules 379–398).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
sequence, selection, iterationFill in the Blanks
Spot the Error
Student with a class code? Join your class →