DIM
Using Array variable. (dimension)
There are
many data in table,
there are times that we'd like to use variable assign the
number,
in BASIC, by making Array variable by 'DIM' command,
to be able to
assign number to variable.
10 dim dt(10)
20 for i=0 to 9
30 read
dt(i)
40 next
50 data 67,18,73,34,68
60 data 47,29,84,93,10
70
max=0
80 for i=0 to 9
90 if dt(i)>max then max=dt(i)
100 next
110
print "MAX=";max
run
MAX=93
OK
First, to prepare array by
'DiM' command that name 'dt', size=10.
'READ' is command that read the data
described by 'DATA' in order.
'DATA' statement may be described anywhere in
the program.
It be substituted into 'dt' number from 0 to 10 in
order.
The next loop, 'dt' be read in order, and looked for which the maximum
is.
Finally to display the result.