Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0984

Tracing loops and assignments

Follow an algorithm one statement at a time instead of guessing its final pattern.

What you will learn

  • Update a variable correctly after assignment.
  • Track a fixed number of loop iterations.

Assignment changes stored state

The arrow in total ← total×3 means calculate the right-hand side using the current value, then store the result in total. It is not an algebraic equation to solve for total.

A trace table records variables as the algorithm executes. Use a fresh row at a consistent point, such as after each loop iteration, and make that convention clear.

Count iterations carefully

Initialisation happens before the loop unless the algorithm places it inside. A loop that repeats twice performs its body exactly twice. Reinitialising the total on every iteration would be a different algorithm.

For conditional loops, inspect when the condition is tested. A pre-condition loop may run zero times; a post-condition loop runs its body at least once.

Put the idea to work

Worked example

Set total ← 3, then repeat total ← total×2 three times. Find the final total.

Show the worked solution
  1. Initial value: 3.
  2. After iterations 1 and 2: 6, then 12.
  3. After iteration 3: 24.

Answer 24

Common mistakes

  • Do not count initialisation as the first loop iteration.
  • Use the updated value in the next iteration.
Recall without your notes

What can you explain now?

Set x←1, then repeat x←x+4 twice. What is x?

Compare with the explanation

9

The successive values are 1,5,9.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Keep learning Computer Science (9-1)

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 4 syllabus. Cambridge states that 0984 has the same subject content as 0478, with 9–1 grading. Three retained introductory lessons remain available but are not counted as syllabus-mapped teaching. The 2023–2025 syllabus remains unmapped. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. Practical programming in an executable browser workspace, full timed-paper practice and human subject-teacher review remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.