How to resolve the algorithm Guess the number/With feedback step by step in the FTCBASIC 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 FTCBASIC 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 FTCBASIC programming language
Source code in the ftcbasic programming language
rem Hilo number guessing game
rem compile with FTCBASIC to 704 bytes com program file
use time.inc
use random.inc
define try = 0, tries = 0, game = 0
gosub systemtime
let randseed = loworder
let randlimit = 100
do
gosub intro
gosub play
gosub continue
loop try = 0
end
sub intro
bell
cls
print "Hilo game"
crlf
return
sub play
gosub generaterand
+1 rand
0 tries
let game = 1
print "Guess the number between 1 and 100"
crlf
do
+1 tries
input try
crlf
if try = rand then
let game = 0
print "You guessed the number!"
print "Tries: " \
print tries
endif
if game = 1 then
if try > rand then
print "Try lower..."
endif
if try < rand then
print "Try higher..."
endif
endif
crlf
loop game = 1
return
sub continue
print "Enter 0 to play again or 1 to EXIT to DOS"
input try
return
You may also check:How to resolve the algorithm Primality by Wilson's theorem step by step in the PL/I programming language
You may also check:How to resolve the algorithm Multisplit step by step in the F# programming language
You may also check:How to resolve the algorithm Square form factorization step by step in the Sidef programming language
You may also check:How to resolve the algorithm Pinstripe/Display step by step in the Raku programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the NetRexx programming language