0% found this document useful (0 votes)
6 views

chap3_record

A record is a fundamental data structure in computer science that consists of a collection of fields of potentially different data types, allowing for heterogeneous data storage. Records are defined by specifying a record type, which includes the data types of each field, and can be accessed using a member access operator. They are commonly used in programming languages and can be stored in various mediums, serving as a key component in data structures and file organization.

Uploaded by

wegabrice05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

chap3_record

A record is a fundamental data structure in computer science that consists of a collection of fields of potentially different data types, allowing for heterogeneous data storage. Records are defined by specifying a record type, which includes the data types of each field, and can be accessed using a member access operator. They are commonly used in programming languages and can be stored in various mediums, serving as a key component in data structures and file organization.

Uploaded by

wegabrice05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CHAPTER 5 : RECORD

INTODUCTION
in computer science, a record (also called a structure, struct, or compound
data) is a basic data structure.A record is a collection of fields, possibly of
different data types, typically in a fixed number and sequence.The fields of a
record may also be called members, particularly in object-oriented
programming; fields may also be called elements, though this risks confusion
with the elements of a collection.

For example, a date could be stored as a record containing a numeric year field,
a month field represented as a string, and a numeric day-of-month field. A
personnel record might contain a name, a salary, and a rank. A Circle record
might contain a center and a radius—in this instance, the center itself might be
represented as a point record containing x and y coordinates.
Records are distinguished from arrays by the fact that their number of fields is
determined in the definition of the record, and by the fact the records are a
heterogenous data type; not all of the fields must contain the same type of data.[6

A record type is a data type that describes such values and variables. Most
modern computer languages allow the programmer to define new record types.
The definition includes specifying the data type of each field and
an identifier (name or label) by which it can be accessed. In type theory, product
types (with no field names) are generally preferred due to their simplicity, but
proper record types are studied in languages such as System F-sub. Since type-
theoretical records may contain first-class function-typed fields in addition to
data, they can express many features of object-oriented programming.

Records can exist in any storage medium, including main memory and mass
storage devices such as magnetic tapes or hard disks. Records are a fundamental
component of most data structures, especially linked data structures.
Many computer files are organized as arrays of logical records, often grouped
into larger physical records or blocks for efficiency.

Course of level 1 SWE at ISLAPE by TAGA SIGNE


I- Declaration of record
Before a record can be created or saved, the record format must be specified by
means of a record type declaration.

The synthax to declare record in algorithm is as follows :

TYPE rec-type IS RECORD


F1 : type1;
F2 : type2;
.
.
.

Fn : typen;
END RECORD;
Or
type
record-name = record
field-1: field-type1;
field-2: field-type2;
...
field-n: field-typen;
end;

Example:
TYPE Employee IS RECORD
ID : IDType;
Name : NameType;
Gender : GenderType;
NumDepend : Natural;
Rate : NonNegFloat;
END RECORD;
Example:
TYPE Fraction IS RECORD
Numerator: Integer;
Denominator: Positive;
END RECORD;

Course of level 1 SWE at ISLAPE by TAGA SIGNE


II- ACCESSING FIELDS OF A RECORD

To access any field of a record, we use the member access operator (.).

Example
Clerk : Employee;
Janitor : Employee;
Clerk.ID := 1234;
Clerk.Name := "Caryn Jackson ";
Clerk.Gender := Female;
Clerk.NumDepend := 3;
Clerk.Rate := 7.50;

Eample :
1- write an algorithm that sum two fraction
2- write an algorithm that sum two complexs numbers

Course of level 1 SWE at ISLAPE by TAGA SIGNE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy