Create a user defined record
Use these records to store collections of dataÂ
Perform standard algorithms on arrays of records
For a BMI program we could store the following values in six parallel arrays:
Name
Height
Weight
Age
Allergies
BMI
We can store these in one record structure where each one will have these 6 pieces of data (fields)
Declares a record structure called personÂ
That has six fields
In an exam situation if you were asked to store 40 person records you would use the following code:
So we now have an array of pupil records called people.Â
At each position in the people array there is a person record, which has its own set of fields.
If we were printing out a single name from a parallel array we would use:
If we were printing out a single name from a parallel array we would use:
If we were printing out all the names using parallel arrays
If we were printing out all the names from an array of records
If we were assigning values in parallel arrays.
If we were assigning values to a field.
File reading using an array of records is very similar to using parallel arrays