Data Representation 1. User-defined Data types These data types are generally accepted by the programmers who writes program for th...
1. User-defined Data types
These data types are generally accepted by the programmers who writes program for the “users”, that provide platform for the user interface. When the programmer uses the user-defined data type for programming, the programmer uses such data.
2. Non-composite user-defined data types
It doesn’t depend on other data types. It does not include data in reference to other types, some examples can be integer or real numbers. These built-in-types require for it to be named by the identifier. Two examples of such non-composite user-defined data types are:
a. Enumerated data type
It is a data type that is defined by the number of possible values assigned to the variables. The following pseudo code shows the example of the data type.
TDirections = (North, East, South, West)
Tdays = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday)
The variables that is assigned to the values can be declared in the following example.
DECLARE Direction1: TDirection
DECLARE StartDay: Tdays
# Enumerated Data type look like string values, but are not.
Another example can be thorugh the comparison statement in use with values and variables. For example:
DECLARE Weekend: Boolean
DECLARE Day: Tdays
Weekend = TRUE IF Day = Friday
b. Pointer data type
It is a dta type that is in reference with the memory location. This data type is used to construct the varying data structuring and storing it in the memory space.
But it differs to the type of data that is being pointed. The following pseudo code represents the illustration of the definition.
TMyPointer = ^<Type name>
The use of “^” symbol is only required to input the data type, but not required in the declaration in the pointer data type.
DECLARE MyPointer = TMyPointer
The stored variables can be used and retrieved from addressed location in the pointer data type. The pointer variable is also called, ‘dereferenced’.
3. Composite User-Defined Data type
Compsoite Data type has reference to atleast one another data type. Examples display the concept of composite user-defined data type.
a. Record Data type
It is widely used and most common data type, it keep track of the values by collecting them together in coherent form as a whole. It has fixed number of component, but varies in the types.
For example, to record the student’s detail in a program. The pseudo code for the data type woud be.
DECLARE StudentFirstName: STRING
DECLARE StudentSurName: STRING
DECLARE DateAdmitted: NUMBER
DECLARE Fees: Currency
To retrieve the data stored, one can access them using dot notation:
Student1. DateAdmitted #15/05/2016#