Skip to content
IGCSE·Tuition

Computer Science · Topics

Repetition and arrays for IGCSE Computer Science

Loops and arrays are where a short program stops being obvious and starts needing a written trace.

On this page
  1. What should you know before starting?
  2. One orienting example
  3. In what order should you study the lessons?
  4. What traps catch students in this topic?
  5. How to use the practice set

This topic is about making a program repeat steps, and storing a list of values so a loop can work through them. Repetition means loops. An array is a row of values under one name, reached by an index.

It follows algorithm design in the Computer Science learning guide and comes before validation, verification and testing. Totals, searches and counts all use the pattern you learn here.

What should you know before starting?

You should be able to read an assignment such as Total ← Total + 5, and an IF statement with a condition. You should also know what a variable is. If these feel shaky, step through a few lines in the pseudocode trace trainer first.

One orienting example

This loop adds the numbers 1 to 4.

Total ← 0
FOR i ← 1 TO 4
   Total ← Total + i
NEXT i
OUTPUT Total
iTotal after
11
23
36
410

The output is 10. Change the end value to 5 and it becomes 15. Every lesson in this module adds one idea to this picture: how a loop stops, where it goes wrong and how it works through an array.

In what order should you study the lessons?

  1. Trace a count-controlled loop: FOR loops with a fixed number of passes. Learn the trace table here.
  2. Trace a condition-controlled loop: WHILE and REPEAT, where a test decides when to stop.
  3. Repair an off-by-one error: find loops that run one pass too many or too few.
  4. Find a maximum in a supplied list: the standard pattern of scanning an array with a stored largest value.
  5. Use an array index without confusing it with a value: separate position from content.

Then work the mixed practice set and log slips in the mistake log. For checking your own code, the Python reasoning sandbox runs short exercises.

What traps catch students in this topic?

  • Counting gaps instead of values. FOR 1 TO 5 runs five times, not four.
  • Reading UNTIL as “while”. REPEAT stops when the UNTIL condition is true.
  • Fixing the output instead of the loop. Adding one to the answer hides the fault.
  • Starting a maximum at 0. It fails when every value is negative.
  • Adding the index instead of the value. i and Data[i] are different.
  • Forgetting the bounds. ARRAY[1:5] has no position 0 and no position 6.

How to use the practice set

Attempt each question on paper and write the trace table before you read the answer. Check the working line by line, not only the final result. Then use the routing list at the end of the set to go back to the right lesson.

Which notation your exam uses depends on your exam year, so confirm it on the Cambridge syllabus page. If you want a teacher to look at how you trace, our online one-to-one Computer Science tuition is built around working through your own attempts.

Questions people ask

Do I need to write loops from memory or just trace them?

Expect both: reading and tracing a given loop, and completing or writing one for a task. Tracing builds the habit of checking every pass, which also helps when you write. Check how your exam year assesses programming on the Cambridge syllabus page.

Will I use pseudocode or Python?

This site uses Cambridge-style pseudocode, with Python where it helps. Which notation your paper uses depends on your exam year. Confirm the year with your exam centre, then read the matching syllabus on the Cambridge page.

What is the quickest way to improve at tracing?

Trace on paper with a table every time, one row per pass, before running anything. Then compare your table with a tool. The first row that differs shows you the exact line where your reasoning slipped.

Why do array questions go wrong so often?

Usually because the index and the value stored there get mixed up, or the loop bounds are one out. Write separate columns for the index and the value, and check the first and last pass.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you follow loops in class but your trace tables drift in the exam, a one-to-one teacher can work through your own attempts and find the line where it starts.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

9,000+ students helped through our service