logo

Pearson Edexcel GCSE (9-1) Computer Science practice

An algorithm processes numerical data. Trace the output of the following pseudocode for `NUM = 25`: ``` INPUT NUM IF (NUM MOD 2 == 0) AND (NUM > 10) OUTPUT "Even and greater than ten" ELSE IF (NUM >= 20) OR (NUM == 5) OUTPUT "Twenty or five" ELSE OUTPUT "Other" END IF OUTPUT NUM DIV 3 OUTPUT NUM ^ 2 ``` [6 marks]

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

exam_style

Style

Topic

Algorithms

Exam-style question

Try this first

An algorithm processes numerical data. Trace the output of the following pseudocode for `NUM = 25`: ``` INPUT NUM IF (NUM MOD 2 == 0) AND (NUM > 10) OUTPUT "Even and greater than ten" ELSE IF (NUM >= 20) OR (NUM == 5) OUTPUT "Twenty or five" ELSE OUTPUT "Other" END IF OUTPUT NUM DIV 3 OUTPUT NUM ^ 2 ``` [6 marks].

Answer and explanation

Concise answer

Tracing for NUM = 25:

Why this is correct

1 mark for correctly evaluating `(NUM MOD 2 == 0)` as FALSE. 1 mark for correctly evaluating `(NUM > 10)` as TRUE. 1 mark for correctly evaluating the first IF condition to FALSE, leading to the ELSE IF block. 1 mark for correctly evaluating `(NUM >= 20) OR (NUM == 5)` as TRUE, and thus correctly identifying the first output as "Twenty or five". 1 mark for correctly calculating `NUM DIV 3` as 8.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

Flashcard 1 of 6

Press Space to flip, arrows to move

Related practice questions