think of the array, tally, as a set of pigeon-holes numbered 2 to 12. Each time a particular score
occurs the tally of that score is increased by throwing a stone into the corresponding pigeon hole.
In the second (short form) FOR loop, the subscript is number. As the value of number changes from 2
to 12 all the values of the tallies are printed.
Notice that in the DIM statement for a numeric array you need only declare the number of variables
required. There is no question of maximum length as there is in a string array.
If you have used other versions of BASIC you may wonder what has happened to the NEXT
statement. All SuperBASIC structures end with END something. That is consistent and sensible but
the NEXT statement has a part to play as you will see in later chapters.
SELF TEST ON CHAPTER 6
You can score a maximum of 16 points from the following test. Check your score with the answers in
the "Answers To Self Tests" section at the end of this Beginner's Guide.
1. Mention two difficulties which arise when the data needed for a program becomes numerous and
you try to handle it without arrays (two points).
2. If, in an array, ten variables have the same name then how do you know which is which?
3. What must you do normally in a program, before you can use an array variable?
4. What is another word for the number which distinguishes a particular variable of an array from the
other variables which share its name?
5. Can you think of two ideas in ordinary life which correspond to the concept of an array in
programming?(two points)
6. In a REPeat loop, the process ends when some condition causes an EXIT statement to be
executed. What causes the process in a FOR loop to terminate?
7. A REPeat loop needs a name so that you can EXIT to its END properly. A FOR loop also has a
name, but what other function does a FOR loop name have?
8. What are the two phrases which are used to describe the variable which is also the name of a
FOR loop?(two points)
9. The values of a loop variable change automatically as a FOR loop is executed. Name one
possible important use of these values.
10. Which of the following do the long form of REPeat loops and the long form of FOR loops have in
common? For each of the four items either say that both have it or which type of loop has it.
1. An opening keyword or statement.
2. A closing keyword or statement.
3. A loop name.
4. A loop variable or control variable. (four points)
PROBLEMS ON CHAPTER 6
1. Use a FOR loop to place one of four numbers 1,2,3,4 randomly in five array variables:
card(1), card(2), card(3), card(4), card(5)