
ASSIGNING VALUES TO RECORD ELEMENTS
These statements assign values to the individual elements of the
record todays_date,
todays_date.day := 21; todays_date.month := 07; todays_date.year := 1985;NOTE the use of the .fieldname to reference the individual fields within todays_date.
readln( todays_date.day, todays_date.month, todays_date.year );Click here for answer
program RECORD_INTRO (output);
type date = record
month, day, year : integer
end;
var today : date;
begin
today.day := 25;
today.month := 09;
today.year := 1983;
writeln('Todays date is ',today.day,':',today.month,':',
today.year)
end.
Records of the same type are assignable.
var todays_date, tomorrows_date : date; begin todays_date.day := 9; todays_date.month := 7; todays_date.year := 1976; tomorrows_date := todays_date;The last statement copies all the elements of todays_date into the elements of tomorrows_date.
This statement adds one to the value stored in the field day of the record tomorrows_date.
tomorrows_date.day := tomorrows_date.day + 1;
