This tool runs a short pseudocode program one line at a time and records every variable in a trace table. It is for students who can read code but cannot predict the output, or who get a wrong result and do not know which line caused it.
Pseudocode trace trainer
You can read the code but the output is never what you expected.
Everything you enter stays on this device.
How do I use it?
- Choose a program. The code is shown with line numbers.
- Enter a whole number for n, from 0 to 15, and press “Run and trace”.
- Read the trace table from top to bottom: each row is one step, with the line that ran and the new variable values.
- Answer the debugging questions, then press “Check answers”.
How does it work?
Each program is stored as plain data that lists its assignments, IF and ELSE choices, FOR and WHILE loops, and OUTPUT. A small interpreter reads that data and adds one trace row for every step.
A FOR line is recorded each time the loop variable takes a new value. A WHILE or IF line is recorded each time its condition is checked, together with whether it was true or false.
Integer division (DIV) and remainder (MOD) are supported. Dividing by zero, or using a variable before it has a value, stops the trace with a message rather than returning a made-up number.
A short worked example
Take the sum program with n = 3: total ← 0, then FOR i FROM 1 TO 3 adds i to total. The trace shows total as 1, then 3, then 6.
The program outputs 6. The FOR line is recorded three times, one for each value of i, which makes a good debugging question.
Now try the program with a bug. It loops to n − 1, so for n = 5 it outputs 10 instead of 15, and the tool points out that the loop stops one value early.
What are its limits?
The tool runs a small set of reviewed programs, not a full programming language, and it cannot run your own project code. A strict limit of 100 steps stops any loop that does not finish.
It teaches the tracing habit, not a full debugging workflow. Your own programming project stays your own work, written and tested by you.
Where does it connect to the lessons?
The trainer supports tracing code when the output is not what you expected and when your code runs but gives the wrong result. If you can follow code but not write it, read understanding a program but not writing your own.
For form-level topics, see Computer Science Form 4 and Form 5. The Computer Science hub shows the full map.
If one step of tracing keeps going wrong, SPM Computer Science tuition gives you a teacher to work through it with you. It starts with the one-hour trial class (from RM50).
Common questions
Can I type my own code into the tool?
No. The tool runs only the reviewed programs on the page, stored as plain data, and your only input is one whole number. It never evaluates code you type, so nothing unsafe can run.
Why does the trace stop after 100 steps?
A loop whose condition never becomes false would run forever. The step limit stops it and tells you so. In your own code, the usual fix is to change a variable inside the loop so the condition can turn false.
What is a trace table?
A trace table lists the value of every variable after each line runs. Writing one by hand stops you from keeping values in your head, which is where most tracing mistakes happen.
Does this cover the whole SPM Computer Science syllabus?
No. It covers assignment, selection, FOR and WHILE loops and output in a simple pseudocode. Other topics, such as networks or data representation, are not part of this tool.
A teacher working one-to-one can trace a program with you on your own code, so the habit of tracking each variable line by line becomes automatic, while your project stays your own work.
- Online one-to-one lessons for your child with an experienced teacher.
- Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
- Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.