How to resolve the algorithm Guess the number step by step in the Euphoria programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Guess the number step by step in the Euphoria programming language

Table of Contents

Problem Statement

Write a program where the program chooses a number between   1   and   10. A player is then prompted to enter a guess.   If the player guesses wrong,   then the prompt appears again until the guess is correct. When the player has made a successful guess the computer will issue a   "Well guessed!"   message,   and the program exits. A   conditional loop   may be used to repeat the guessing until the user is correct.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Guess the number step by step in the Euphoria programming language

Source code in the euphoria programming language

include get.e

integer n,g
n = rand(10)

puts(1,"I have thought of a number from 1 to 10.\n")
puts(1,"Try to guess it!\n")

while 1 do
    g = prompt_number("Enter your guess: ",{1,10})
    if n = g then
        exit
    end if
    puts(1,"Your guess was wrong. Try again!\n")
end while

puts(1,"Well done! You guessed it.")

  

You may also check:How to resolve the algorithm QR decomposition step by step in the SequenceL programming language
You may also check:How to resolve the algorithm Make directory path step by step in the Rust programming language
You may also check:How to resolve the algorithm Doubly-linked list/Traversal step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Read a file line by line step by step in the Wren programming language
You may also check:How to resolve the algorithm Sorting algorithms/Heapsort step by step in the Janet programming language