8.2

Topic 8

Arrays

  • IGCSE Computer science 0478
  • 2 min read
  • Syllabus 2026, 2027 and 2028

Objectives

  1. 1

    Declare and use one-dimensional (1D) and two-dimensional (2D) arrays

  2. 2

    Understand the use of arrays

  3. 3

    Write values into, and read values from, an array using iteration

Cambridge IGCSE Computer Science 0478 syllabus 2026-2028, 8.2 Arrays (copied for internal use as permitted by Cambridge)

Detailed · Deep study

1Declaring arrays

array

A data structure that holds a fixed number of elements, all of the same data type, under one identifier; each element is accessed using its index.

Fig. 1Indexes in 1D and 2D arrays.

A one-dimensional (1D) array is like a list; a two-dimensional (2D) array is like a table, with an index for the row and an index for the column. The first index can be zero or one – Cambridge pseudocode usually uses 1, but Python lists start at 0.

DECLARE StudentNames : ARRAY[1:30] OF STRING
DECLARE NoughtsAndCrosses : ARRAY[1:3, 1:3] OF CHAR
StudentNames[1] ← "Ali"
NoughtsAndCrosses[2, 3] ← 'X'
Declaring and assigning single elements.

2Why use arrays?

Without an array, storing 30 names would need 30 separate variables. An array keeps related data together, so it can be processed with a loop using a variable as the index – the same few lines of code work for 30 or 3000 items. Arrays are used for searching, sorting, totalling and finding the maximum and minimum.

See Topic 7 · Algorithm design and problem-solvingLinear search and bubble sort on arrays are in 7.1.

3Using iteration with arrays

DECLARE Names : ARRAY[1:5] OF STRING
DECLARE Index : INTEGER
FOR Index ← 1 TO 5
    OUTPUT "Enter name ", Index
    INPUT Names[Index]                 // write values into the array
NEXT Index
FOR Index ← 1 TO 5
    OUTPUT Names[Index]                // read values from the array
NEXT Index
Writing to and reading from a 1D array using a loop; the variable Index is used as the index.
DECLARE Marks : ARRAY[1:3, 1:4] OF INTEGER
DECLARE Row : INTEGER
DECLARE Column : INTEGER
DECLARE RowTotal : INTEGER
FOR Row ← 1 TO 3
    RowTotal ← 0
    FOR Column ← 1 TO 4
        INPUT Marks[Row, Column]
        RowTotal ← RowTotal + Marks[Row, Column]
    NEXT Column
    OUTPUT "Total for student ", Row, " is ", RowTotal
NEXT Row
Nested iteration fills a 2D array row by row and totals each row.

4Exam focus

Key words: array; element; index; one-dimensional; two-dimensional; row; column; nested iteration.

Quick self-check

Answer in your head first, then reveal.

  1. DECLARE Temperatures : ARRAY[1:50] OF REAL (1 for name/size, 1 for data type).

  2. Data can be processed with a loop using the index / less code / related data kept together (1).

  3. 90 (1).

  4. Max ← Scores[1] (1); loop 2 to 20 (1); IF Scores[i] > Max THEN Max ← Scores[i] (1); OUTPUT Max after the loop (1).

Finished this subtopic? Track it on your subject page.