Back to Grade 5
Coding: loops, conditions and variables
Questions at easy, medium and hard levels. Pick a level and get a fresh set every time, with instant feedback.
Learn it Trace a program by writing the value of each variable after every step. Loops repeat; "if" conditions choose which step runs.
Example: total = 0. For i from 1 to 5: total = total + i × i.
- i = 1: total = 1. i = 2: total = 1 + 4 = 5.
- i = 3: 5 + 9 = 14. i = 4: 14 + 16 = 30.
- i = 5: 30 + 25 = 55.
Loading questions…