Trace Tables
What is a Trace Table and Why do We Need One?
A trace table will help you to trace the value of variables after each line of code has executed. This is a good way to find logical errors.
Exam Style Trace Tables
The following code is taken from a GCSE exam paper. It shows a control conidtioned loop written in pseudocode. To the right we can see each value of x
and y
that will be stored when the code is executed. The output column is blank until the loop has completed, you then see the output.
You can check these values by creating this program, breakpointing and watching the variables as you step through the code.
Pseudocode
x = 15
y = 0
while x > 0
y = y + 1
x = x -y
endwhile
print(y)
Trace Table
Want to know more?
Check the following video for a step by step guide.