Chapter
6
Grocery
Expense
ARRAYS
Gas
Clothes
Expense
Expense
An array is a group of related data values stored consecutively
in memory. The entire group of data values is referred to by one
variable name. Each data value is called an
element
of
the array.
A
subscript
is an integer used to refer
to
each element
of
the ar-
ray. For example, an array named
A
may contain 3 elements re-
ferred to as:
A(1) A(2) A(3)
Note:
Normally array elements start with Element
0;
however,
to
simplify this example, it starts with Ele-
ment
1.
You can modify the initial array element base-
number with the OPTION BASE statement.
You
can use each
of
these elements
to
store a separate data
value, such as:
A(1)
=
.10
A(2)
=
.20
A(3)
=
.30
You can imagine an array as a row
of
boxes, with the numbers
on them
to
identify them. Each box can hold a different value.
For example, Array A may hold your expenses.
This is a 1-dimensional array, because elements are arranged in
a
single row and only one subscript is used
to
an element. For
example, A(1) holds your grocery expense.
59