Computer Science · May / June 2025 · Paper 1 TZ2 SL · Question 5
Adapt for 2027Tracing a loop with nested selection is taught, but the IB pseudocode should be rewritten in Python or Java.
IBCS
As printed in the paper
The question as text
5. Construct a trace table for the following algorithm: N = 5 S = 0 R = 0 loop while N > 0 A = N mod 3 if A = 0 then S = S – N else if A = 1 then S = S + N else S = S + 1 end if end if R = R + S N = N - 1 end loop output ('The result is ', R) [6]
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

