A Matter of Record

The concept of the array is a powerful one. However, it is a limited one in the sense that we can only have arrays of a single type of data. That is we can't have an array where the first element is a string, the next is an integer, the third is another string and the fourth is a floating point number. So we can't use an array to store the information about a student, for example. It would be nice if we could have a representation of data we could call a student which had items like these: Of course, others could be added, but these are enough to illustrate what we're interested in.

Many programming languages all the way back to one of the first (i.e. COBOL) include the ability to this. In general, we call such collections of data records . The advantage of records is that we can treat complex data in dual ways. First we can look at the individual components of that data, and on the other hand, we can treat it as a single, named entity.

Another difference we generally find between arrays and records has to do with how we reference parts of them. For arrays, in most languages, we must refer to the element of interest by an integer number, but with records we usually give the elements names. (Remember, though, that in C we can define symbolic constants with the #define directive that can give names to any numbers including integers.) This will often win us some additional clarity in our code.

Which of the following are not suitable for arrays assuming we don't want to store numbers in their written form?

A description of a video with the title and price

The temperatures measured on a grid one yard on a side across a football field

The set of attributes of a car with the name, model year and mileage

The set of model names used by a particular automobile manufacturer for a particular year