ITPEC IP April 2024 Question 5
ITPEC IP April 2024 — Question 5 of 100
The missing condition is score greater than or equal to 65: score ≥ 65. The preceding if (score ≥ 80) has already handled every score of 80 or more. Therefore, when execution reaches this elseif, the score is known to be below 80, and testing only the lower boundary score ≥ 65 selects exactly the range 65 through 79.
If that condition is false, the next test score ≥ 50 selects 50 through 64; all remaining lower scores reach Fail. This descending order makes an explicit upper bound unnecessary in each branch.
Answer (a)
Why not others:
- (b) uses OR, so almost every integer satisfies at least one side of the condition
- (c) requires a score to be at most 65 and at least 79 simultaneously, which is impossible
- (d) is true for every score below 80, including scores below 65, so those scores would incorrectly receive B
Key rule: In a descending if/elseif chain, earlier branches exclude higher ranges, so each later branch usually needs only its lower threshold.
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.