How to resolve the algorithm Guess the number/With feedback step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Guess the number/With feedback step by step in the Icon and Unicon programming language
Table of Contents
Problem Statement
Write a game (computer program) that follows the following rules:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the Icon and Unicon programming language
Source code in the icon programming language
procedure main()
smallest := 5
highest := 25
n := smallest-1 + ?(1+highest-smallest)
repeat {
writes("Pick a number from ", smallest, " through ", highest, ": ")
guess := read ()
if n = numeric(guess)
then {
write ("Well guessed!")
exit ()
}
else if n < numeric(guess)
then write ("Your guess is too high")
else if n > numeric(guess)
then write ("Your guess is too low")
else write ("Did you enter a number?")
}
end
You may also check:How to resolve the algorithm Two's complement step by step in the PL/M programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the SparForte programming language
You may also check:How to resolve the algorithm Descending primes step by step in the RPL programming language
You may also check:How to resolve the algorithm Terminal control/Unicode output step by step in the Clojure programming language
You may also check:How to resolve the algorithm Stack traces step by step in the Perl programming language