Programming Constructs and Operators: Question 7

Syllabus 8.1

Multiple choice 1 mark

A training course grades each learner's final score, out of 100, using this pseudocode, with categories nested up to three levels deep.

DECLARE Score : INTEGER
DECLARE Grade : STRING
Score ← 68
IF Score < 40 THEN
    Grade ← "Fail"
ELSE
    IF Score < 60 THEN
        Grade ← "Pass"
    ELSE
        IF Score < 75 THEN
            Grade ← "Merit"
        ELSE
            Grade ← "Distinction"
        ENDIF
    ENDIF
ENDIF
OUTPUT Grade

What is output when this algorithm is run?

Choose an answer to check it, then compare with the worked solution below.

Show worked solution Hide worked solution

Worked solution

Step 1: Identify the nested structure

There are three levels of nesting here:

  • Level 1: IF Score < 40 THEN ... ELSE ...
  • Level 2 (inside the level-1 ELSE): IF Score < 60 THEN ... ELSE ...
  • Level 3 (inside the level-2 ELSE): IF Score < 75 THEN ... ELSE ...

Because each IF sits inside the ELSE of the one before it, exactly one of the four Grade assignments runs, as soon as one condition is found to be true, none of the deeper conditions are even reached.

Step 2: Trace with Score = 68

  • Level 1: 68 < 40? False → move into the ELSE branch (level 2).
  • Level 2: 68 < 60? False → move into the ELSE branch (level 3).
  • Level 3: 68 < 75? TrueGrade ← "Merit".

Because the level-3 condition was true, execution never reaches the final ELSE (which would assign "Distinction").

Step 3: Confirm the output

OUTPUT Grade prints:

Merit

This is option A.

Step 4: Why the other options are wrong

  • Option B (“Pass”) assumes that failing the first two conditions is enough on its own to reach the “Pass” branch. But “Pass” is only assigned when Score < 60 is true. For Score = 68 that condition is false, so the algorithm must continue into the third, innermost IF instead of stopping at “Pass”.
  • Option C (“Distinction”) assumes that reaching the innermost ELSE structure automatically gives “Distinction”, but the innermost IF Score < 75 THEN must be checked first, since 68 < 75 is true, Grade is set to "Merit" and the Distinction branch is never reached.
  • Option D (“Fail”) comes from misreading the very first condition, Score < 40. Since 68 < 40 is false, the Fail branch is skipped immediately, before any of the other conditions are even considered.

Final answer

  • The algorithm outputs “Merit”, option A.