Exam-style question
Try this first
Explain the difference between an array and a record. Give one suitable example of information that could be represented by each.
Model answer
What a good answer should say
- An array is an organised collection of values, normally using elements of the same data type.
- A record is a collection of related fields, where the fields may use different data types.
- An array could represent the scores of 30 students, with each element holding an integer.
- A record could represent one student, with fields such as a name string, an age integer and a date/time value for a relevant date.
Explanation
Why this works
The distinction is based on how the data is grouped. An array is suitable when there are multiple values of a common type, while a record is suitable when different pieces of information describe one entity.
The examples demonstrate appropriate use of both data types.
Common mistake
No common mistake is linked to this question yet.
