Beginner's Programming Tutorial in QBasic

(Kiana) #1

The above program can also be written like this:
DIM vars(5)
FOR x = 1 to 5
NEXTvars(x) = x * 2
FOR x = 1 to 5
NEXTPRINT vars(x),
Output:
2 4 6 8 10


Strings


You can also create an array of string variables.
DIM vars$(5)
vars$(1) = "Two"vars$(2) = "Four"
vars$(3) = "Six"vars$(4) = "Eight"
vars$(5) = "Ten"
PRINT vars$(1), vars$(2), vars$(3), vars$(4), vars$(5)
Output:
Two Four Six Eight Ten

Free download pdf