DAY$(8) = "Memorial Day"
No. The DIM
statement asks for a collection of seven things,
numbered one through seven.
Only subscripts (item numbers) 1, 2, 3, 4, 5, 6, and 7 can be used.
Here is a program that uses an array:
DIM DAY$(1 TO 7) ' Make an array of seven strings. LET DAY$(1) = "Monday" ' Make "Monday" the first string. PRINT "The day is", DAY$(1) ' Print out the first string. END
The program is complete. You can enter it into QBasic and run it. It writes out:
The day is Monday
When this program begins, it creates an array. The array holds seven items, and each item is a string. Each string starts out as the "empty string"—it contains no characters. Then the string "Monday" is put into the first position. Here is a picture of the array after the first two statements have executed:
Monday |
|
|
|
|
|
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
The array is a collection of numbered "slots".
In this picture there are seven slots,
numbered 1, 2, 3, ... 7.
"Monday" is in the first slot, DAY$(1)
.
Fill in the blank so that "Tuesday" is put into the second slot.
LET DAY$(_____) = "Tuesday"