Page 80 - DCAP407_DATA_STRUCTURE
P. 80
Unit 4: Pointers
In the above example, Gender and Year does not require any qualification as each refers to a unique
item in the structure.
On the other hand, consider Age which is occurring more than once in the record. Therefore, in order to
specify a particular item, we will have to qualify the name by using appropriate group names in the
structure. This qualification can be done by using decimal points or periods to separate group items
from sub items.
If we want to refer to the Age of the mother then, it can be done in the following way:
Application.Mother.Age or Mother.Age
This reference is said to be fully qualified. Sometimes, we can include more identifiers for clarity.
In the above example, if the first line of the record structure is replaced by:
1 Application (20)
The Application is defined to be a file with 20 records, and then every item will automatically become a
20 element array. Some languages allow the Gender in the Application to be referenced as:
Application.Gender[5] or Gender[5]
So, the name of the mother of the fifth child can be referenced by writing:
Application.Mother.Age[5] or Mother.Age[5]
Texts can use functional notation instead of dot notation to represent qualifying
identifiers. For example, Age (Mother(Application )) instead of Application. Mother.
Age.
4.7 Representation of Records in Memory - Parallel Arrays
Records can contain a collection of non-homogenous data. Therefore, the elements of a record may not
be stored in an array. In C language, structures can be used to store such non-homogenous data records.
Consider the record structure of kindergarten school Application . You can store
the record in C by the following declaration, which defines the data aggregate
called structure.
struct Application
{
Char Name[20];
Char Gender[1];
struct Birthday
{
int Month;
int Day;
int Year;
}B;
struct Father
{
char Name[20];
int Age;
}F;
struct Mother
{
char Name[20];
int Age;
}M;
LOVELY PROFESSIONAL UNIVERSITY 73