Searching an array for a value
A loop checks every element against the wanted value. On a match, set Found to TRUE and record the index. If Found is still FALSE at the end, OUTPUT a not found message.
Understanding Searching an array for a value in IGCSE Computer Science Paper 2
What it does: The loop counter Index holds the position of the current element, so copying it into Position records where the value was found. Found starts as FALSE because nothing has been found yet. It only becomes TRUE when a match is made. The loop must run from the lower bound 1 to the upper bound 10. Stopping at 9 would miss the last element. Use = to compare two values. The ← arrow is for assignment, so it cannot be used to test for a match. If every element was checked and none matched, Found never changed to TRUE. The program should then OUTPUT a message such as "Not found".
Common mistakes: When the element matches the target, Found must be set to TRUE. Setting it to FALSE means a match is never recorded. It should be Found ← TRUE. The IF condition compares two values, so it needs the comparison operator =. The ← arrow is only for assignment. It should be IF Names[Index] = Wanted 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 459–468) and word search (Modules 459–478).
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
linear searchFill in the Blanks
Spot the Error
Student with a class code? Join your class →