# Creating a Hi-Lo game in BASIC

Hello Everyone,

Well, I'm teaching myself to program in BASIC via online tutorials. I've read one tutorial on making a Hi-Lo game. Once I had created the game in the tutorial I started editing it, and adding some features.

This is the original version. (In which was still incorrect and I had to fix some typos to get it to work.)
[code]
// The Hi-Lo Game, by [[Insert Your Name Here!]]
2
// Start of each round of the game
clear screen
print "I am thinking of a number between one and ten."

print "Take a guess and I will tell you if it is higher or lower."
// Ask the user what he thinks the answer is with input and put in variable a.
input a
// See if what the user said is right.
if a>5 then
print "Sorry, the number is lower. Press enter to try again."
end if
if aprint "Sorry, the number is higher. Press enter to try again."
end if
if a=5 then print "You got it dude!"
end
end if
// Press enter to continue
input b
goto 2[/code]

In this version you get to repeatedly guess until you are correct.(After you fix the typos.)

In my version you get three tries, then the game ends unless on one of those three tries, you guess the correct answer. The range is 1-10. Here is my version:
[code]
clear screen
print "The Hi-Lo Game"

print "By: Cody Morgan"

print "I am thinking of a number between one and ten."

print "Take a guess and I will tell you if it is higher or lower."

print "You have three tries, if you do not guess the correct answer, you lose."
// Ask the user what he thinks the answer is with input and put in variable a.
input a
// See if what the user said is right.
if a>9 then
print "Sorry, the number is lower. You have two more tries. Good luck."
input b
end if
if a<9 then
print "Sorry, the number is higher. You have two more tries. Good luck."
input b
end if
if a=9 then print "You got it dude!"
end
end if
// Press enter to continue
if b>9 then
print "Sorry, the number is lower. You have one more try. Good luck."
input c
end if
if b<9 then
print "Sorry, the number is higher. You have one more try. Good luck."
input c
end if
if b=9 then
print "You got it dude!"
end
end if
if c>9 then
print "Sorry, the number is lower. You lose."
end
end if
if c<9
print "Sorry, the number is higher. You lose."
end
if c=9
print "You got it dude!"
end
[/code]

I'm using Notepad to edit the code and YABasic to execute it. ( I do not know if this matters or not. )

My problem is, the number in that case is always 9 (unless I change it). I want it to generate a random number when executed that way it can change 9 to any number 1-10.