The document discusses the Pascal programming language and records data type. It provides an introduction to records, explaining that records allow grouping of different data types to define a structure like a book or person. It then shows how to define a record type by specifying the fields and their types. Examples are given to demonstrate defining and accessing fields of record variables. The document also discusses using records within arrays and using the "with" statement to simplify accessing fields. Finally, it provides a sample programming problem about booking airline seats to demonstrate using records.
4. Program Test();
Var
First_name : array [1..100] of String;
Last_name : array [1..100] of String;
Age : array [1..100] of Integer;
Day : array [1..100] of Integer;
Month : array [1..100] of Integer;
year : array [1..100] of Integer;
i,n : Integer;
Begin
Readln(n);
For i:=1 to n do
Read(First_name[i],Last_name[i],Age[i],Day[i],Month[i],year[i]);
Readln;
End.
OMG !!
5. Record
A record is a special type of data structure that, unlike arrays,
collects different data types that define a particular structure such
as a book, product, person and many others. Which defines the
data structure under the Type user definition.
6. How we Define it ?
type
record-name = record
field-1: field-type1;
field-2: field-type2;
...
end ;
7. What Data type it can content ?
Simple DataType
Integer
Real
Char
String
Boolean
8. What Data type it can content ?
complex object
Date (D,M,Y)
Time (H,M,S)
Rectangle (L,W)
Employee (….)
…
multi arrays for multi data type
15. Type
Date = Record
Day, month, year : Integer;
End;
STD = Record
First_name : string[20];
Last_name : String[20];
Age : Real;
DODO : Date;
End;
STD
DODO
F
N
A
M
E
L
N
A
M
E
A
g
e
D M Y
19. For I:=1 to 100 do
Begin
Readln(A[I].First_name);
Readln(A[I].Last_name);
Readln(A[I].Age);
Readln(A[I].Date.year);
Readln(A[I].Date.Month);
Readln(A[I].Date.Day);
End;
20. It is using for accessing record fields directly
without [dot] operator
Accessing fields
without [dot]