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

Process a one-dimensional array with a loop

Use a variable index to read, write, initialise or calculate values across an array.

Section 8 · Programming

Cambridge IGCSE Computer Science 0984 · Programming · 2026–2028 Version 4 · 0984 (9–1) · 8.2
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.2 (Arrays) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. 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. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.

Before you begin

  • Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

What does Scores[Index] select?

What you will learn

  • Assign array elements with iteration
  • Read values through a variable index
  • Use an array in a total or search

A loop visits one element at a time

Use a loop whose range matches the array's declared bounds. An index variable selects the current element: Scores[Index].

The same pattern can initialise elements, read input into them, or output them. The first index may be 0 or 1, so align the loop with the declaration.

Process each element consistently

A total can be calculated by setting Total to zero before the loop and adding each array element inside it.

For a search, compare the selected element with the target and record or output the relevant result. Avoid reading beyond the array's final index.

Pause and explain

Where should Total ← 0 appear when summing an array?

Put the idea to work

Worked example

Total the five values in Scores declared with indexes 1 to 5.

Show the worked solution
  1. Initialise Total ← 0.
  2. Loop Index from 1 through 5.
  3. Add Scores[Index] to Total on each pass.

Answer Total ← 0; FOR Index ← 1 TO 5; Total ← Total + Scores[Index]; NEXT Index.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

A Values array has indexes 1 to 3 and stores 5, 2 and 8. Trace a loop that totals it.

Give me a hint

Add each selected value exactly once.

Compare my reasoning
  1. Start Total at 0.
  2. Add 5, then 2, then 8.
  3. The final total is 15.

Total = 15.

Look for these in your work

  • Index range followed
  • Values added
  • Total correct
2 · Independent

Write a FOR loop to read four integers into Data declared as ARRAY[1:4] OF INTEGER.

Give me a hint

INPUT can target one array element.

Compare my reasoning
  1. Loop Index from 1 to 4.
  2. Read into Data[Index].
  3. Close the loop after the input.

FOR Index ← 1 TO 4; INPUT Data[Index]; NEXT Index.

Look for these in your work

  • Bounds align
  • Variable index used
3 · Transfer

An array has 6 values at indexes 1–6. A search loop tests indexes 1–5 only. What can be missed and how should it be fixed?

Give me a hint

Compare the loop range with the declared range.

Compare my reasoning
  1. The sixth element is never examined.
  2. A matching target at index 6 is missed.
  3. Extend the loop through index 6.

The last element can be missed; search indexes 1 TO 6.

Look for these in your work

  • Missing element identified
  • Range corrected

Common mistakes

  • Using a fixed index in every loop pass
  • Starting or ending the loop outside the declared bounds
  • Initialising the running total inside the loop
Recall without your notes

What can you explain now?

What lets one loop statement access a different array element each pass?

Compare with the explanation

A variable used as the index

The index changes as iteration proceeds.

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.

Make it stick

How does a variable index make array processing reusable?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

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.