Programming languages - AQAData structures - records

Proficient programming requires knowledge of many techniques. These techniques allow for powerful, complex programs to be created.

Part ofComputer ScienceComputational thinking and problem solving

Data structures - records

allow data values of different types that relate to each other to be stored together instead of in different arrays. For example, a record could be declared to hold the information about a board game:

RECORD Boardgame
title
genre
numPlayers
minAge
maxAge
ENDRECORD

This would create a record that stores the title and genre as and the number of players, minimum age, and maximum age as . Each board game would be created as a separate record which could then be held in an array, creating an array of records:

game1 ← Boardgame(‘snap!’,’card’,2,4,99)
game2 ← Boardgame(‘monopoly’,’family’,4,5,70)

This would create two separate records holding the related values for each game. To make this more efficient, an array could be used:

myGames[0] ← Boardgame(‘snap!’,’card’,2,4,99)
myGames[1] ← Boardgame(‘monopoly’,’family’,4,5,70)