The data types of an entity represent the behavior, i.e., operations, functions, and values associated with it. The data types are shown in the diagram below:
The data types are declared as follows:
type1, type1 = type-specifier;
The following example further illustrates it:
type
month, year = string;
tax, bonus = integer;
Integers have various storage sizes and other properties. These are shown in the table below:
Type | Minimum | Maximum | Format |
---|---|---|---|
Integer | -2147483648 | 2147483647 | 32-bits signed |
Cardinal | 0 | 4294967295 | 32-bits unsigned |
Shortint | -128 | 127 | 8-bits signed |
Smallint | -32768 | 32767 | 16-bits signed |
Longint | - 2147483648 | 2147483647 | 32-bits signed |
Int64 | -2 ^ 63 | 2 ^ 63 - 1 | 64-bits signed |
byte | 0 | 255 | 8-bits unsigned |
Word | 0 | 65535 | 16-bits unsigned |
Long word | 0 | 4294967295 | 32-bits unsigned |
Constants allow the declaration of types that have to be kept the same throughout the program. Using them makes the program more readable as the same does not have to be repeated multiple times. Constants are declared as follows:
const_name = contant_value;
The example below further illustrates the use of constants:
default_heading = "I hope you are having a good time on this platform"
counter = 100;
These are user-defined types that allow specific values to be given to a list, as shown below:
type
enum-identifier = (member1, member2, member3, ... )
The example below further illustrates the use of enumerated types:
type
days = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
The mentioned order defines the order of the listed members, e.g., Tuesday is preceded by Monday, and Wednesday is preceded by Wednesday.
These are user-defined types that allow declaring values that fall within a specific range, as shown below:
type
subrange_name = lower_limit ... upper_limit;
The example below further illustrates the use of sub-range types:
type
marks = 1 ... 100;
Types should be declared before variables.
Free Resources