AS · Practice questions · Data types and records

Fields under one name.

Six original Cambridge-style questions on data types and record structures, with mark points.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Type, then field.

01
Recall
[2 marks]

Explain what is meant by a record structure.

  • A (composite / user-defined) data type that holds a set of related data items (fields). ✓
  • The fields can be of different data types and are referred to by one identifier. ✓
02
Apply
[4 marks]

A cinema stores, for each film showing: the film title, the screen number (1 to 12), the ticket price, the date of the showing, whether it is 3D, and an age rating of one character. State the most appropriate data type for four of these items.

  • Title: STRING. ✓
  • Screen number: INTEGER. ✓
  • Ticket price: REAL. ✓
  • Date: DATE; Is 3D: BOOLEAN; Age rating: CHAR (any four correct, 1 mark each). ✓
03
Write
[4 marks]

Write pseudocode to define a record type CarRecord with fields for a registration number, the make, the year of manufacture, the price and whether the car has been sold. Then declare a variable NewCar of this type.

  • TYPE CarRecord ... ENDTYPE enclosing the fields. ✓
  • DECLARE Registration : STRING and DECLARE Make : STRING. ✓
  • DECLARE Year : INTEGER, DECLARE Price : REAL, DECLARE Sold : BOOLEAN. ✓
  • DECLARE NewCar : CarRecord after the type definition. ✓
04
Write
[3 marks]

Using CarRecord and NewCar, write pseudocode statements to store a car with registration AB12 CDE, make Toyota, year 2021, price 15995.00, not yet sold, and then output its make and price.

  • NewCar.Registration ← "AB12 CDE" and NewCar.Make ← "Toyota". ✓
  • NewCar.Year ← 2021, NewCar.Price ← 15995.00, NewCar.Sold ← FALSE. ✓
  • OUTPUT NewCar.Make, " ", NewCar.Price. ✓
05
Write
[5 marks]

Stock is an ARRAY[1:200] OF CarRecord. Write pseudocode to output the registration of every car that is not sold and was made before 2015, and then the total price of those cars.

  • Initialise Total ← 0 before the loop. ✓
  • FOR Index ← 1 TO 200 ... NEXT Index. ✓
  • IF Stock[Index].Sold = FALSE AND Stock[Index].Year < 2015 THEN. ✓
  • Inside: OUTPUT Stock[Index].Registration and Total ← Total + Stock[Index].Price. ✓
  • OUTPUT Total after the loop. ✓
06
Analysis
[3 marks]

A programmer stores the cars in five separate 1D arrays (one per field) instead of one array of records. Give two advantages of using an array of records.

  • All the data about one car is kept together under one identifier and one index. ✓
  • A whole car can be moved, copied or swapped (for example when sorting) in one assignment, so the fields cannot get out of step. ✓
  • Only one array needs to be declared and passed to subroutines (any two, with explanation for the third mark). ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.