ITPEC IP October 2022 Question 5
ITPEC IP October 2022 — Question 5 of 100
The final value of x is 5. Initially x = 2 and y = 3. The first loop changes y to 2 and then x to 2 + 2 = 4. Because y is not yet 1, the loop repeats: y becomes 1 and x becomes 4 + 1 = 5. The termination condition is now satisfied.
Answer (b)
Why not others:
- 4 is the intermediate value after the first iteration
- 7 and 8 result from continuing or adding values not specified by the procedure
Key rule: Execute assignments in sequence and test the loop condition only after both updates.
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 IP past-paper collection or Report an issue.