Displaying every element with OUTPUT in a loop
Inside a FOR loop, this line displays every element of the array in order. Index changes on each pass, so each pass outputs the next element, from the lower bound to the upper bound.
Understanding Displaying every element with OUTPUT in a loop in IGCSE Computer Science Paper 2
What it does: Counting from the upper bound down to the lower bound makes Index visit the elements in reverse, so the last element is output first. Index changes each pass, so StudentNames[Index] outputs the next element each time. Using just the array name does not select one element. Text goes in quotes, but Index and Marks[Index] must be outside the quotes so their values are output. Several values are separated by commas. To count down you need STEP -1. Without STEP, the loop counts up and 10 TO 1 would not run at all.
Common mistakes: NEXT must name the same loop variable as the FOR line. The loop counts with Index, so the last line should be NEXT Index. A fixed index of 1 outputs the first element on every pass. The loop variable must be the index, so the line should be OUTPUT Marks[I].
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
OUTPUT StudentNames[Index]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →