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
| i | Total after |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
| 4 | 10 |
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?
- Trace a count-controlled loop: FOR loops with a fixed number of passes. Learn the trace table here.
- Trace a condition-controlled loop: WHILE and REPEAT, where a test decides when to stop.
- Repair an off-by-one error: find loops that run one pass too many or too few.
- Find a maximum in a supplied list: the standard pattern of scanning an array with a stored largest value.
- 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.
iandData[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.