An array is a 'list'
of data items which are all the same data type.
The data items in an array are called its elements.
Each element has a subscript to
identify it (usually a number...but not necessarily).
A linear
list is a one-dimensional
array, where each item is identified by one subscript.
Example : A linear list (one-dimensional array) of names
called 'NAME' .
Subscript |
Name |
1 |
Julie Stephenson |
2 |
Amanda Platt |
3 |
John Kingsley |
4 |
Nita Cardigan |
5 |
Linda Hanson |
6 |
Oscar Nominee |
NAME[2] denotes the element of the array
NAME which has subscript 2 - ie 'Amanda Platt'.
Processing an array usually
involves a loop. The following procedure would display all
the elements of the above array.
procedure
DisplayArray; |
var i : integer; |
begin |
|
for i = 1 to 6 do |
|
|
output(Name[i]); |
end; |
|