Saturday 17 April 2021

Record Types | PPL | Sebesta | Data Types in Programming Language

                   In this post, we will see Record Types | PPL | Sebesta | Data Types in Programming Language | data types in ppl, data types ppl, elementary data types in programming language, ppl, sebesta, record types  


7. Record Types

 

Definition:

              A record is an aggregate of heterogeneous data elements in which the individual elements are identified by names and accessed through offsets from the beginning of the structure.

 

Differences between Array and Record:

 

1. Arrays are used when all the data values have the

same type and/or are processed in the same way.

 

Records are used when the collection of data values is heterogeneous and the different fields are not processed in the same way.

 

2. Array elements are accessed using Subscripts while Record elements are accessed using Field Names.

 

 

Implementation in Different Programming Languages:

 

i. Records in C, C++, C#

 

              In C, C++, and C#, records are supported with the struct data type.

 

e.g.

Defining Linked List:

struct list

{

int info;

struct list *ptr;

};

 

Defining Linked List variable

struct list node;

 

Defining Binary Tree

struct btree

{

int info;

struct btree *lptr;

struct btree *rptr;

};

 

Defining Binary Tree variable

struct btree node;

 

 

ii. Records in COBOL

 

01   EMPLOYEE-RECORD.

              02 EMPLOYEE-NAME.

                      05 FIRST PICTURE IS X(20).

                      05 MIDDLE PICTURE IS X(10).

                      05 LAST PICTURE IS X(20).

              02 HOURLY-RATE PICTURE IS 99V99.

 

 

 

 

 

 

 

iii. Records in Ada

 

type Employee_Name_Type is record

First : String (1..20);

Middle : String (1..10);

Last : String (1..20);

end record;

 

type Employee_Record_Type is record

Employee_Name: Employee_Name_Type;

Hourly_Rate: Float;

end record;

 

Employee_Record: Employee_Record_Type;

 

iv. Records in Java & C#

              In Java and C#, records can be defined as data classes, with nested records defined as nested classes.

              Data members of such classes serve as the record fields.

 

A compile-time descriptor for a record




Watch following video:

Watch on YouTube: https://www.youtube.com/watch?v=pnnpdPU1Ikg

No comments:

Post a Comment