ITPEC FE Subject B April 2024 Question 1
ITPEC FE Subject B April 2024 — Question 1 of 20
Fill in blanks for a grade-classification function using if/elseif/else.
The table maps scores to letter grades: 80–100 → "D", 50–79 → "P", 0–49 → "F". The function checks from highest range down:
if (score ≥ 80)→ return "D" — covers 80–100elseif (score ≥ 50)→ return "P" — since the first check failed, score is already < 80, so this covers 50–79else→ return "F" — everything below 50
Blank A = ≥ (greater than or equal), because score 80 must be included in the "D" range.
Blank B = "P" (Pass), for scores 50–79.
Blank C = "F" (Fail), for scores 0–49.
Why not others:
- (a) = operator — equality check (score = 80) would only match exactly 80, not a range
- (b) = operator — same problem as (a), plus B and C are swapped
- (c) > operator with B="P", C="F" — score > 80 excludes 80 itself, which should get "D"
- (d) > operator with B="F", C="P" — wrong operator AND swapped grades
- (f) ≥ operator but B="F", C="P" — correct operator, but grades are swapped: 50–79 would get "F" instead of "P"
Key rule: In chained if/elseif, each branch inherits the negation of all previous conditions — so elseif (score ≥ 50) implicitly means score < 80 AND score ≥ 50.
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.