ITPEC FE Subject B April 2026 Question 4

Source exam: ITPEC FE Subject B April 2026Topic: Software Development

ITPEC FE Subject B April 2026 — Question 4 of 20

A is num mod 10, B is integer part of (num ÷ 10), and C is n mod sum = 0.

The loop peels digits off the right-hand end:

  • A must add the last digit to the running total, which is num mod 10
  • B must then discard that digit, which is integer part of (num ÷ 10)
  • The loop ends when num reaches 0, so the final test cannot use num any more — it must compare the original n against the digit sum: n mod sum = 0

For 156: sum picks up 6, then 5, then 1 = 12, and 156 mod 12 is 0, so the function returns true.

Answer (f)

Why not others:
- (a), (b) and (c) — swap A and B, so the code adds the truncated quotient and keeps the last digit; for 156 num becomes 6 and stays 6 forever, an infinite loop

- (e) — has A and B right but tests num mod sum, and num is 0 by then, so 0 mod sum is 0 for every input and the function always returns true

- (d) — tests sum = n, which asks whether the digit sum equals the number itself; that holds only for single-digit values

Key rule: After a digit-stripping loop the working variable is exhausted. Any final check must refer to the original argument, which is exactly what separates the correct option from the one that always returns true.

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.