Guess The Number
' Guess The Number for Liberty BASIC and Just BASIC
' by Shawn Hartnell
print "'Ello. I'm a little man inside Liberty BASIC."
print "See if you can guess my random number."
print "It will be between 1 and 100."
print
gosub [init]
[askNumber]
input "Guess my number : > "; a
if a < 1 or a > 100 then
print "Please enter a number between 1 and 100"
print
goto [asknumber]
end if
if a < number then
print : print "Your number is too low."
guess = guess - 1
end if
if a > number then
print : print "Your number is too high."
guess = guess - 1
end if
if a = number then
print "Congratulations, you win!"
end
end if
if guess > 0 then goto [askNumber]
print "Sorry, you failed to guess my number."
print "Game over."
end
[init]
number = int(rnd(1)*100)+1
guess = 10
return
page revision: 2, last edited: 25 Mar 2007 12:13