Introduction to BASIC   Arrays

An array is a sequence of variables so that each variable is referred with a number called an index (or a subscript).
Each variable in an array is called an indexed variable.
Arrays must be declared by DIM statements.
10 DIM A(4)
makes an array A and indexed variables A(1),A(2),A(3) and A(4) available.
An index can be indicated by a numerical expression.
For Example,
20 LET N=2
30 LET A(N)=10

An array declaration can contain a specification of the lower bound of the indices as follows.
DIM A(0 TO 10)

Example. A program that makes a frequency distribution table of class width 10.
This Program terminates when a negative number is entered.

100 DIM m(0 TO 10)
110 FOR i=0 TO 10
120    LET m(i)=0
130 NEXT i
140 DO 
150    INPUT x
160    IF x<0 THEN EXIT DO
170    LET i=INT(x/10)
180    LET m(i)=m(i)+1
190 LOOP
200 PRINT  "marks", "count"
210 FOR i=0 TO 10
220    PRINT i*10, m(i)
230 NEXT i
240 END