Skip to main content
๐Ÿ“œ WAYPOINT LESSON

The state table

โญโญ intermediateโณ 10 min read๐Ÿ“ Lesson 85 of 256

One row per statement, one column per variable; right side first.

A state table is the exam's native language. One row per step, one column per variable โ€” never keep state in your head.

int a = 2;
int b = a * 3;
a = a + b;
b = a - b;

| step | statement | a | b | | ---- | -------------- | - | - | | 1 | a = 2 | 2 | โ€“ | | 2 | b = a * 3 | 2 | 6 | | 3 | a = a + b | 8 | 6 | | 4 | b = a - b | 8 | 2 |

Two discipline rules make tracing mechanical:

  1. Right side first, then assign. In step 3, a + b uses the old values (2 and 6) โ€” a becomes 8, not 12. Assignment never re-reads its own left side.
  2. New row per statement, even when nothing changes. Gaps are where mistakes hide. If a variable is untouched, copy its value down.

Swap puzzles like the one above appear on every exam: after a = a + b; b = a - b;, b holds the old a (8 โˆ’ 6 = 2), and a third statement a = a - b; would complete the swap. Tracing beats memorizing the trick โ€” the table always tells you where you are.