News:

Welcome to RetroCoders Community

Main Menu

guess computer number game in euphoria

Started by ron77, Aug 15, 2023, 02:23 PM

Previous topic - Next topic

ron77

include std/console.e
include std/get.e

procedure main()
    integer target = rand(100)
    integer guess
    integer attempts = 0
    --printf(1, "number is: %d\n\n", target)
    atom true = 1
    while true = 1 do
        printf(1, "Guess a number between 1 and 100: ")
        guess = prompt_number("", {1, 100})
        attempts += 1
        
        if guess < target then
            puts(1, "Too low! Try again.")
        elsif guess > target then
            puts(1, "Too high! Try again.")
        else
            printf(1, "Congratulations! You guessed the number in %d attempts.", attempts )
            true = 0
        end if
    end while
end procedure

main()