ITPEC FE Subject B April 2026 Question 1
ITPEC FE Subject B April 2026 — Question 1 of 20
1, 2 — trace the assignments in order, remembering that each one copies a current value.
Starting state: x = 1, y = 2, z = 3, ar = {0, 0}.
- •
y ← x— y becomes 1 (the initial 2 is gone from here on) - •
ar[x] ← y— x is 1, soar[1]becomes 1; array is now{1, 0} - •
z ← y— z becomes 1 - •
x ← z— x becomes 1 (unchanged in effect) - •
ar[2] ← z + ar[1]—1 + 1= 2; array is now{1, 2}
Output: 1, 2
Answer (c)
Why not others:
- (a) 1, 0 — leaves ar[2] at its initial 0, skipping the last assignment
- (b) 1, 1 — computes z + ar[1] with the initial ar[1] of 0, missing that ar[1] was set to 1 two lines earlier
- (d) 2, 1, (e) 2, 2 and (f) 2, 3 — all begin with ar[1] = 2, which keeps the original y = 2 and ignores the very first assignment y ← x
Key rule: Write the variables down and update them line by line. Every option starting with 2 fails on the same slip, so getting y ← x right immediately halves the answer group.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.