logo

Pearson Edexcel GCSE (9-1) Computer Science practice

Consider the following pseudocode: `count = 0` `data = [10, 20, 5, 30]` `FOR each item in data DO` `IF item > 15 THEN` `count = count + 1` `END IF` `END FOR` `OUTPUT count` What value will be outputted?

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: `count = 0` `data = [10, 20, 5, 30]` `FOR each item in data DO` `IF item > 15 THEN` `count = count + 1` `END IF` `END FOR` `OUTPUT count` What value will be outputted?.

  1. A.0
  2. B.1
  3. C.2
  4. D.3

Answer and explanation

Concise answer

2

Why this is correct

Initially, `count` = 0. For `item` = 10 (not > 15), `count` remains 0. For `item` = 20 (> 15), `count` becomes 1. For `item` = 5 (not > 15), `count` remains 1. For `item` = 30 (> 15), `count` becomes 2. Finally, 2 is outputted.

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