3. Arrays
Docs / Pseudocode / Arrays
CAIE 0478 & 9618 Arrays

3. Arrays (1-Based Indexing)

1D and 2D array declarations with strict 1-based indexing, element access, boundary loops, and whole-array assignment in Cambridge pseudocode.

Arrays are fixed-length structures of identical data type, accessible by consecutive index numbers. Square brackets denote indices. A lower bound of 1 is standard across Cambridge syllabuses.

Array Declarations & Usage

PSEUDOCODE Run in Sandbox
// runnable
// Array declaration demo
DECLARE StudentNames : ARRAY[1:30] OF STRING

// 2D array
DECLARE NoughtsAndCrosses : ARRAY[1:3,1:3] OF CHAR

DECLARE SavedGame : ARRAY[1:3,1:3] OF CHAR
DECLARE n, Index : INTEGER
n <- 1

// Accessing individual elements
StudentNames[1] <- "Ali"
NoughtsAndCrosses[2,3] <- 'X'
StudentNames[n+1] <- StudentNames[n]

// Whole-array assignment (same size and type)
SavedGame <- NoughtsAndCrosses

// Assigning a group of elements requires a loop
FOR Index <- 1 TO 30
   StudentNames[Index] <- ""
NEXT Index

Key Examination Notes

  • Cambridge pseudocode uses 1-based indexing by default (e.g. ARRAY[1:10]).
  • 2D arrays use comma separation inside brackets (e.g. Matrix[row, column]).
  • Direct whole-array assignment (e.g. ArrB <- ArrA) is valid only when both arrays have identical dimensions and element types.