Code Tracing
CS

Slow down. See the logic.

Code tracing studio

Follow curated C examples one step at a time and see how variables, call frames and output change.

Educational model traces for these exact examples — not a C interpreter or live execution. Arbitrary source can be reviewed in the free-entry static debugger, but is not executed here.

Accumulator loop

Trace a for loop that adds 1 through 4.

sum.cC
1#include <stdio.h>2int main(void) {3    int sum = 0;4    for (int i = 1; i <= 4; ++i) {5        sum += i;6    }7    printf("%d\n", sum);8    return 0;9}

Step 1 of 12

CURRENT LINE 3

Initialize the accumulator.

Variable watch

Variable / frameCurrent value
sum0

Output so far

No output yet.
C Logic Lab · Learn the why behind the code.Progress linked to this browser · No sign-in required
⚡Make an app like this, free