ITPEC FE Morning April 2018 Question 8
ITPEC FE Morning April 2018 — Question 8 of 80
Flowchart: Repeated Subtraction Division — identifying integer division implemented via a loop that repeatedly subtracts the divisor.
The flowchart initializes s ← 0 (counter) and t ← x (working value). It then loops: while t ≥ y, it subtracts y from t and increments s. The loop exits when t < y.
This is classic repeated subtraction division:
- s counts how many times y fits into x → quotient of x ÷ y
- t holds what's left over → remainder of x ÷ y
Trace with x = 13, y = 4:
| Iteration | t (before) | t ← t − y | s ← s + 1 |
|---|---|---|---|
| 1 | 13 | 9 | 1 |
| 2 | 9 | 5 | 2 |
| 3 | 5 | 1 | 3 |
Loop exits because t = 1 < 4 = y. Result: s = 3 (quotient), t = 1 (remainder). ✓ 13 ÷ 4 = 3 remainder 1.
Why not others:
- (a) Swaps quotient and remainder — s is the count (quotient), not the leftover
- (c) Divides y ÷ x, but the algorithm divides x by y (t starts at x, subtracts y)
- (d) Same wrong direction (y ÷ x) with swapped roles
Key rule: Repeated subtraction of y from x counts the quotient in the counter and leaves the remainder in the working variable.
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.