logo

Pearson Edexcel GCSE (9-1) Computer Science practice

A loop runs 3 times. In each iteration, a variable `total` (initially 0) is updated by adding the iteration number (starting from 1). What is the final value of `total`?

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

A loop runs 3 times. In each iteration, a variable `total` (initially 0) is updated by adding the iteration number (starting from 1). What is the final value of `total`?.

  1. A.3
  2. B.4
  3. C.6
  4. D.9

Answer and explanation

Concise answer

6

Why this is correct

Initially, `total` = 0. Iteration 1: `total` = 0 + 1 = 1. Iteration 2: `total` = 1 + 2 = 3. Iteration 3: `total` = 3 + 3 = 6. The loop finishes, and the final value of `total` is 6.

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