See below.
The basic idea is: (1) write a counting loop that matches the array, and (2) in the loop body, do what you want done to one array slot.
Here is the complete program. You can copy it into a QBasic window and run it if you want. If you do, you may wish to change the array size from 100 back to 10.
DIM NUM( 1 TO 100 ) ' An array of 100 floating point numbers FOR COUNT=1 TO 100 ' Visit each slot of the array LET NUM( COUNT ) = 13.33 ' Put the value 13.33 into this slot NEXT COUNT ' Usually much more code goes here ' Print each item the array FOR COUNT=1 TO 100 ' Visit each slot of the array PRINT NUM( COUNT ) ' Print out the item NEXT COUNT END
This program is not practical. If you want to print 13.33 on the screen 100 times, there are easier ways to do it. However, this program is an outline of many practical programs. Such programs first place whatever values are needed in the array, and then do something to each value. Each value is then worked on by code that is sandwiched between the initial loop and the final loop (where the comment says "Usually much more code goes here.")
It would be nice if the PRINT
statement said which array slot it
was printing out each time, something like:
Item 1: 13.33 Item 2: 13.33 Item 3: 13.33 Item 4: 13.33 ....