30 lines
1.0 KiB
Plaintext
30 lines
1.0 KiB
Plaintext
10 REM Create a four-dimensional array (with 120 elements in all):
|
|
20 DIM array(1, 2, 3, 4)
|
|
30
|
|
40 REM Set a specific element of the array:
|
|
50 array(1, 0, 3, 2) = PI
|
|
60
|
|
70 REM Modify the value of the element:
|
|
80 array(1, 0, 3, 2) += 1
|
|
90
|
|
100 REM Print the value of that element:
|
|
110 PRINT array(1, 0, 3, 2)
|
|
120
|
|
130 REM Print the number and sizes of the dimensions:
|
|
140 ndim = DIM(array())
|
|
150 nele = 1
|
|
160 PRINT ' "The array has "; ndim; " dimensions:"
|
|
170 FOR dim = 1 TO ndim
|
|
180 PRINT " Dimension "; dim "'s maximum index is "; DIM(array(), dim)
|
|
190 nele *= DIM(array(), dim) + 1
|
|
200 NEXT
|
|
210 PRINT "The total number of elements is "; nele
|
|
220
|
|
230 REM Initialise the first row of the array:
|
|
240 array() = 9, 8, 7, 6, 5
|
|
250
|
|
260 REM Print some array statistics:
|
|
270 PRINT ' "The sum of all the elements in the array is "; SUM(array())
|
|
280 PRINT "The modulus (square-root of the sum of squares) is "; MOD(array())
|
|
290 PRINT "The RMS (root-mean-square) value is "; MOD(array()) / SQR(nele)
|