You have a block of pseudocode, a list of variables and a table with empty boxes, and the clock is ticking. Trace tables are one of the most reliable ways to pick up marks in IGCSE Computer Science (0478), and also one of the easiest ways to lose them through a single careless slip. This guide shows you how IGCSE Computer Science trace tables work, with a step-by-step method and three worked examples you can try yourself.
What is a trace table?
A trace table is a grid that records the value of each variable (and any output) every time a line of an algorithm runs or changes something. You act like the computer: you follow the code exactly, one step at a time, and write down what happens, even if you can already guess the answer.
Examiners use trace tables because they test whether you can follow logic precisely. The topic sits in the algorithm design and problem-solving part of the Cambridge IGCSE Computer Science 0478 syllabus. Check the current syllabus on the Cambridge International website for the exact wording, as the pseudocode conventions it uses are what exam questions follow.
The five-step method for any trace table
- 1Read the whole algorithm first. Find the inputs, the loops, the conditions and the OUTPUT lines.
- 2Set up the columns. One column for each variable, plus one for OUTPUT. Keep them in the order they appear in the code.
- 3Fill in the starting values. Variables set before the loop go in the first row.
- 4Run one line at a time. Only write a value in the table when it changes. Use a finger or pencil to follow the line you are on.
- 5Check the stopping condition. Before you leave a loop, check the test again and confirm it is really false (or true, for REPEAT UNTIL).
Tip: Never "skip ahead" because the pattern looks obvious. The questions are designed so that one value, usually the last one or the first one, breaks the pattern.
Worked example 1: a simple FOR loop
Look at this pseudocode (written in the style of the syllabus):
Total ← 0
FOR Count ← 1 TO 4
Total ← Total + Count
NEXT Count
OUTPUT TotalTrace it:
| Count | Total | OUTPUT |
|---|---|---|
| 0 | ||
| 1 | 1 | |
| 2 | 3 | |
| 3 | 6 | |
| 4 | 10 | |
| 10 |
The output is 10. Notice the two things students often forget: the starting value of Total (0) belongs in the table, and the output only happens once, after the loop has finished.
Worked example 2: a WHILE loop with a condition
Number ← 20
Steps ← 0
WHILE Number > 5
Number ← Number - 6
Steps ← Steps + 1
ENDWHILE
OUTPUT Steps
OUTPUT Number| Number | Steps | Number > 5? | OUTPUT |
|---|---|---|---|
| 20 | 0 | TRUE | |
| 14 | 1 | TRUE | |
| 8 | 2 | TRUE | |
| 2 | 3 | FALSE | |
| 3 | |||
| 2 |
The loop stops when Number becomes 2, because 2 > 5 is false. The outputs are 3 and then 2. The common trap here is stopping at 8 (because 8 − 6 = 2 "looks like the end") without checking the condition first, or forgetting that the test happens before each pass of a WHILE loop.
Worked example 3: IF inside a loop
This one counts how many values meet a condition.
Marks ← [45, 72, 38, 90]
Passes ← 0
FOR Index ← 1 TO 4
IF Marks[Index] >= 50 THEN
Passes ← Passes + 1
ENDIF
NEXT Index
OUTPUT Passes| Index | Marks[Index] | Marks[Index] >= 50? | Passes | OUTPUT |
|---|---|---|---|---|
| 0 | ||||
| 1 | 45 | FALSE | 0 | |
| 2 | 72 | TRUE | 1 | |
| 3 | 38 | FALSE | 1 | |
| 4 | 90 | TRUE | 2 | |
| 2 |
The answer is 2. If a question gives you the extra column for the condition, fill it in. Even if it doesn't, writing it out in the margin can stop you applying an IF the wrong way round.
Note that the syllabus pseudocode guide uses an arrow (←) for assignment, and it numbers arrays in a way set out in that guide. In an exam, follow whichever convention the question paper shows you.
Mistakes that cost marks
- Off-by-one errors. A loop that runs FOR 1 TO 4 runs four times, not three. Count the passes.
- Updating a variable too early. If two variables change in one loop, write each change on the correct row.
- Writing the output at the wrong time. OUTPUT inside the loop prints every time; OUTPUT after ENDWHILE prints once.
- Using your own guess instead of the code. If the answer looks odd, trust the algorithm, not your intuition.
- Missing the initial values. The row before the loop starts often carries marks.
Common mistakes like these are also reported in revision guidance such as Tutopiya's 0478 exam trends overview, which highlights off-by-one errors and wrong loop conditions as typical problem areas.
What the question might ask after the table
A trace table is often a stepping stone. The follow-up question may ask you to state the purpose of the algorithm (for example, "counts how many marks are 50 or above"), to find an error, or to change the code. Read the command word carefully. If you are unsure whether "state", "describe" or "explain" needs a longer answer, our guide to IGCSE command words breaks them down.
How to practise trace tables
- 1Copy one of the examples above and change a number (for example, make the loop run to 6, or the threshold 60). Predict the new output before you trace it.
- 2Trace on paper, not just in your head. The skill is accuracy under exam conditions.
- 3Run the same logic in a real programming language and compare the result to your table. If you disagree, find out exactly which row went wrong.
- 4Cover your notes and explain to someone, out loud, what each line is doing. If you cannot explain a line, you probably will not trace it reliably either. This is the idea behind learning by teaching, supported by research on explaining material to others (Fiorella & Mayer, 2013, Contemporary Educational Psychology).
Where TeachVerse fits
TeachVerse is a study app for Cambridge IGCSE where you learn a topic by teaching it to your own AI pupil. Try explaining how a WHILE loop is checked before each pass, and see whether your pupil can then answer an exam-style question on it. If it gets the answer wrong, you know which part of your explanation needs work. You can then lock the topic in with topical papers and mark schemes (original questions written in the style of Cambridge IGCSE papers), flashcards, and a study plan. TeachVerse is independent and not affiliated with or endorsed by Cambridge.
Quick recap
- A trace table records every variable's value as the algorithm runs.
- Follow the five steps: read, set up columns, starting values, one line at a time, check the stopping condition.
- Check loop conditions each time and count the passes carefully.
- Practise by changing numbers, predicting the output and then tracing.
Want to learn the topic by teaching it instead of re-reading it? Try TeachVerse free.