46
Arrays can be either one-
or
two-dimensional. A one-dimensional array can be
thought
of
as a row
of
successive data items. A two-dimensional array can be
thought
of
as
a matrix
of
rows and columns. Figure 6 shows a schematic repre-
sentation
of
both types
of
arrays.
One-Dimensional Array Named A
A(1)
A(2)
A(3)
A(4)
Two-Dimensional Array Named 8
8(1,1) 8(1,2)
8(1,3)
8(2,1)
8(2,2) 8(2,3)
8(3,1)
8(3,2) 8(3,3)
8(4,1) 8(4,2)
8(4,3)
Figure 6. Schematic Representation
of
One- and Two-Dimensional Arrays
Each element
in
an array
is
referred
to
by the name
of
the
array followed by a sub-
script
in
parentheses, which indicates
the
position
of
the
element within
the
array.
The general form for referring
to
an array element
is:
array name (rows, columns)
where array name
is
the
name
of
the
entire array, and rows, columns are any
positive arithmetic expressions whose truncated integer values are greater than zero
and
less
than
or
equal
to
the
corresponding dimension
of
the
array.
The expression
in
a subscript referring
to
an element
of
a one-dimensional array gives
the position
of
the
element
in
the
row, counting from left
to
right. Thus, the third
element
of
a one-dimensional array named A can be referred
to
by the symbol A(3),
as
in
this example:
A(3)
=
25
./
/