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

Work with two-dimensional arrays

Use row and column indexes to represent a table, then process both dimensions with nested iteration.

Cambridge IGCSE Computer Science 0478 · Programming · 2026–2028 Version 6 · 8.2
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. 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.

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 Grid[2,3] identify?

What you will learn

  • Declare and access a two-dimensional array
  • Use two index values for one element
  • Read or write every cell using nested loops

Two dimensions represent rows and columns

A two-dimensional array has an index for each dimension, such as DECLARE Grid : ARRAY[1:3, 1:4] OF INTEGER.

Grid[2,3] selects row 2, column 3. Each element has the declared data type, and both sets of bounds must be respected.

Nested loops visit every cell

Use an outer loop for rows and an inner loop for columns. The inner loop runs once for every row, so a 3 by 4 array contains 12 cells.

A variable can be used in each index. State the lower bounds because indexes may begin at 0 or 1.

Pause and explain

How many cells are in an array with 4 rows and 5 columns?

Put the idea to work

Worked example

How many elements are in Grid : ARRAY[1:3, 1:4] OF INTEGER, and which element is Grid[2,3]?

Show the worked solution
  1. There are 3 row indexes and 4 column indexes.
  2. Multiply 3 by 4 to get 12 elements.
  3. The two indexes select row 2, column 3.

Answer Grid contains 12 elements; Grid[2,3] is the value at row 2, column 3.

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

Declare a 2D array for a 3-by-3 game board of characters and assign X to row 2, column 1.

Give me a hint

Use two inclusive bounds and CHAR elements.

Compare my reasoning
  1. Declare both index ranges as 1:3.
  2. Choose CHAR because each cell holds one mark.
  3. Assign the value at [2,1].

DECLARE Board : ARRAY[1:3, 1:3] OF CHAR; Board[2,1] ← 'X'.

Look for these in your work

  • Two dimensions
  • CHAR type
  • Correct indexes
2 · Independent

A score table has 4 students and 3 tests. How many values are stored, and how many times does the inner loop run in total?

Give me a hint

The inner loop processes every test for each student.

Compare my reasoning
  1. There are 4 rows and 3 columns.
  2. There are 4 × 3 = 12 values.
  3. The inner loop runs 3 times on each of 4 rows, 12 total.

12 values; the inner body runs 12 times.

Look for these in your work

  • Array size
  • Nested iteration count
3 · Transfer

Nested loops output a table in which the row loop runs 2 times and the column loop runs 5 times. Describe the output order and total cells.

Give me a hint

The complete inner loop runs for each row.

Compare my reasoning
  1. For row 1, columns 1–5 are output.
  2. Then row 2's columns 1–5 are output.
  3. There are 2 × 5 = 10 cells.

The table is output row by row, five columns per row, for ten cells total.

Look for these in your work

  • Order described
  • Cell count

Common mistakes

  • Supplying only one index for a 2D array
  • Swapping the row and column indexes
  • Using a loop bound that differs from the declaration
Recall without your notes

What can you explain now?

How many index values are needed to access one element in a 2D array?

Compare with the explanation

Two

One index selects each dimension, such as row and column.

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

Why does a 2D array normally need nested loops to visit every element?

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

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus 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.