News:

Welcome to RetroCoders Community

Main Menu

Simple Guessing Game.

Started by electricwalrus, Sep 10, 2022, 08:31 AM

Previous topic - Next topic

electricwalrus

This is a very simple freebasic program. Guess my number between 1-100. You have 7 trys to guess the number. Simple enough?

Screen 17

Dim guess as Byte
Dim number as byte
Dim GuessCount as integer

Randomize Timer

cls
Print "Welcome to the Guessing Game!"
Print
Print "I am thinking of a number between 1 and 100."
number = int(rnd*100)+1
'Print number
Print "Can you guess my number?"

Do
    GuessCount = GuessCount + 1
    Print
    Input "Your guess: ", guess
    if guess = number then
        Print "Well done! You guessed my number."
        Sleep
        End
    end if
    If guess < number Then
        Print "Higher..."
    else
        Print "Lower..."
    End if
    Print "You have " + str(7 - GuessCount) + " guesses remaining..."
Loop until GuessCount = 7

Print "You have guessed 7 times... Not good enough. You have no more guesses."
Print "Game over."
Sleep
End