Arrays, Lists and Records

GCSE Computer Science · Programming

Storing lots of data together

A single variable holds one value. Data structures let you store many related values under one name. At GCSE you need arrays (and lists), and often records.

Arrays

An array is an ordered collection of items of the same data type, stored under one name and accessed by an index (position number).

  • Most languages start indexing at 0, so the first item is index 0.
  • Example: scores = [10, 25, 8, 42]
  • scores[0] = 10 (the first item)
  • scores[3] = 42 (the fourth item)
  • You can read and change items by index: scores[1] = 30.

Looping through an array

Because arrays are indexed, a FOR loop is perfect for processing every item:

total = 0
for i = 0 to 3
   total = total + scores[i]
next i

This adds up all four scores.

2D arrays

A two-dimensional array is like a table or grid, accessed with two indexes (row, column): grid[2][1]. Useful for things like a seating plan, board game, or spreadsheet of data.

Lists

A list is similar to an array but is usually more flexible — it can grow and shrink, and (in some languages) hold mixed data types. Common operations: append (add to the end), remove, and insert.

Records

A record stores related data of different types together as fields — like one row of a database.

Example — a record for a student:

FieldTypeValue
nameString"Aisha"
ageInteger15
averageReal78.5
presentBooleanTrue

You access a field by name, e.g. student.age. An array of records can store many students.

Array vs record

ArrayRecord
Data typesAll the sameCan be different
Accessed byIndex (number)Field name
Good forA list of similar itemsOne thing with several attributes

Worked example

For colours = ["red", "green", "blue"], what is colours[1]?

  • Indexing starts at 0, so index 1 is the second item = "green". ✓

Common mistakes

  • Forgetting arrays are usually zero-indexed, causing off-by-one errors.
  • Trying to store different data types in one array (use a record instead).
  • Reading past the end of the array (e.g. scores[4] when the last index is 3).

Exam tips

  • State that arrays are fixed type, index-accessed; records are mixed type, field-accessed.
  • Be ready to trace a loop that sums or searches an array.
  • For 2D arrays, be clear which index is the row and which is the column.

Key facts to remember

  • Array = ordered, same-type items accessed by index (usually from 0); 2D arrays use two indexes.
  • List = like an array but flexible (can grow/shrink).
  • Record = related fields of different types accessed by name; an array of records stores many.
Don't understand a part?

Sign in and ask our AI tutor to explain any passage in plain English.

Try AI explanations →

More on Programming

Programming Fundamentals Selection and Iteration Subroutines: Functions and Procedures String Manipulation

← All GCSE Computer Science notes