Hi there, I was just curious of how to do one little thing.
Let's say I wanted QBASIC to generate random numbers between 1 and 10 and based on that number, it would print out a particular word associated with that number (something I would define,) but then I would want it to do it again, but not including the previous number generated (thus not printing the same word twice if it repeats 10 times.
In case I'm not clear...
if I say that such and such variable = "joe"
and such and such variable = "mary"
and so on with eight other names...
and i want it to randomly select one of them, and then do it until all 8 names are used and none are repeated... how can I do this?
Thanks!
Robbie
Easy Question I'm sure...
Moderators:Administrator, Global Moderator
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
Re: Easy Question I'm sure...
Here ya' go!!!
;D :D ;)
;D :D ;)
Code: Select all
SCREEN 13
RANDOMIZE TIMER
DIM Names$(1 TO 10)
FOR X = 1 TO 10
READ Names$(X)
NEXT
DO
RandomName = INT(RND * 10) + 1
IF Names$(RandomName) <> "" THEN
PRINT Names$(RandomName)
Names$(RandomName) = ""
Counted = Counted + 1
END IF
LOOP UNTIL Counted = 10
DATA Dr_Davenstein,has,taken,the,liberty,to,finish,your,homework,assignment
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!