help wanted I am learning qbasic
I am trying to create variables dependent on a input.
For example If I input G=3
I would like to create variables
q1
q2 &
q3
If I input G=5
I would like to create variables
q1
q2
q3
q4 &
q5
How can this be done
You have to use an array:
INPUT "Enter the number of variables to be created: ", G
DIM q(1 TO G)
then to refer to a particular variable (let's use 3 for an example) do this:
PRINT q(3)
or A = q(3) + 5
To print a list of all the variables, do this:
FOR i = 1 TO G
PRINT q(i)
NEXT
Tom Lake