Records Flashcards

All 7 cards in this deck

What is a record?

A data structure that groups together related items of data (fields) about one thing, e.g. a Car record with the fields make, price and noOfDoors.

What is a field in a record?

A single item of data within a record, e.g. a name or an email address.

True or false? Every field in a record must be of the same data type.

False. Unlike an array, a record can hold fields of different data types.

Give one advantage of storing data about one item in a record rather than in separate variables.

All the related data is kept together under one identifier, so the item can be handled as a single unit, e.g. stored in an array of records or passed to a subroutine as one parameter.

How is a record defined in AQA pseudo-code?

e.g. a Car with a make, a price and a number of doors

Between RECORD Car and ENDRECORD, each field is listed with its data type:
make : String
price : Real
noOfDoors : Integer

In AQA pseudo-code, how is a variable created from a record definition?

e.g. a Car record for a Ford costing £8,000 with 5 doors

Use the record's name with the field values in brackets, in the same order as the fields were defined:
myCar ← Car('Ford', 8000.0, 5)

In AQA pseudo-code, how do you read or change one field of a record?

e.g. the price field of myCar

Use dot notation: the variable's name, a dot, then the field name.

  • read: OUTPUT myCar.price
  • change: myCar.price ← 7500.0