PDA

View Full Version : New BASIC program


Sandy Cagle
February 4th, 2008, 04:39 PM
Here is a letter guessing game in basic

10 REM Letter - guessing game in BASIC
20 REM Generate a random number from 65 to 90
30 REM (ASCII 65 is A and ASCII 90 is Z)
40 NUM = (INT(RND * 26)) + 65
50 CA$ = CHR$(NUM)
60 CLS
70 PRINT "*** Letter Guessing Game ***"
80 PRINT
90 PRINT "I am thinking of a letter..."
100 INPUT "What is your guess"; UG$
110 TR = TR + 1
120 IF (UG$ > CA$) THEN GOTO 150
130 IF (UG$ < CA$) THEN GOTO 180
140 GOTO 210
150 PRINT "Your guess was too high"
160 PRINT "Try again..."
170 GOTO 200
180 PRINT "Your guess was too low"
190 PRINT "Try again..."
200 GOTO 100
210 REM Here if guess was correct
220 PRINT "***Congratulations! You got it right!"
230 PRINT "It took you only"; TR; "tries to guess."
240 END

Sandy Cagle
February 14th, 2008, 09:02 PM
For those who are interested, you will have to have basic or qbasic, you run this program and then you will have to give a name to your newly created program, I'd suggest word.bas, then from qbasic choose run word.bas and it should work, very limited, but it works. Also, your answer needs to be in capital letters.

DoctorPepper
February 16th, 2008, 11:22 AM
Here is a letter guessing game in basic

10 REM Letter - guessing game in BASIC
20 REM Generate a random number from 65 to 90
30 REM (ASCII 65 is A and ASCII 90 is Z)
40 NUM = (INT(RND * 26)) + 65
...
240 END

Sandy, I'd recommend putting a "RANDOMIZE seed" statement (where 'seed' is your seed value (like TIMER)) between line 30 & 40, otherwise, your random number generator will generate the same number each time the program is run. At least when using QBASIC on a PC.

Sandy Cagle
February 16th, 2008, 04:38 PM
It's been a long time... S was the only right answer in it.