Outputting the result of a linear search
After the search loop, check the Found flag: if TRUE, output the position (Index) where the target was found, otherwise output a not-found message. Covers first, last and missing items.
Understanding Outputting the result of a linear search in IGCSE Computer Science Paper 2
What it does: A target at the first item sets Found to TRUE at Index 1, so the output is Found at 1. The result is only known once the search loop is over. Then one IF...ELSE on the Found flag outputs either the position or the not-found message.
Common mistakes: ELSE never has THEN after it in Cambridge pseudocode. Only IF takes THEN. The line should be just ELSE. ← assigns a value. A condition must compare, so it should use =: IF Found = TRUE THEN.
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 296–306) and word search (Modules 296–316).
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
IF Found = TRUE THEN OUTPUT "Found at ", Index ELSE OUTPUT "Not found" ENDIFFill in the Blanks
Spot the Error
Student with a class code? Join your class →