logo

Pearson Edexcel GCSE (9-1) Computer Science practice

Consider the following pseudocode: `x = 10` `y = 5` `IF x > y THEN` `x = x + y` `ELSE` `y = y - x` `END IF` `OUTPUT x` What is the output of this algorithm?

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

At a glance

MCQ

Type

practice

Style

Topic

Algorithms

Exam-style question

Try this first

Consider the following pseudocode: `x = 10` `y = 5` `IF x > y THEN` `x = x + y` `ELSE` `y = y - x` `END IF` `OUTPUT x` What is the output of this algorithm?.

  1. A.5
  2. B.10
  3. C.15
  4. D.20

Answer and explanation

Concise answer

15

Why this is correct

Initially, x is 10 and y is 5. Since x (10) is greater than y (5), the IF condition is true. Thus, x becomes x + y, which is 10 + 5 = 15. The algorithm then outputs the value of x, which is 15.

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