EasyManuals Logo

Texas Instruments TI-99/4A User Reference Guide

Texas Instruments TI-99/4A
204 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #174 background imageLoading...
Page #174 background image
Secret Number
This
program
is
a
secret
number
game.
The
object
is to guess
the
randomly chosen
number
between
1
and
an
upper
limit you
inpllt
For
each
guess. you
enter
two numbers: a low
and
a high guess.
The
computer
will tell you if
the
secret
number
is less than.
greater
than.
or
between
the two
numbers
you enter. When
yOll
think
yOll
know
the
number.
enter
the
same
value for both
the
low and high
guesses.
The
RANDOMiZE
statement
ensures
a different
sequence
of
numbers
each
time
the
program
is run,
MSGl$
and
MSG2$
are
repeatedly
used
in
PRINT
statements.
The
CALL
CLEAR
statement
clears
the
screen
The
INPUT
statement
stops
the
program
and
waits
for you to
enter
a limit.
Then
the
secret
number
is
generated.
and
the
screen
is
cleared. N is used to
keep
track
of
the
number
of guesses you
make.
This
INPUT
statement
accepts
your low
and
high guesses.
If
you
enter
the
same
number
for both guesses
and
you guess the
secret
number.
the
program
transfers
to
line
300.
If
the
senet
number
is
less
than
your low number, the
program
transfers
to line 260.
If
the
secret
number
is
greater
than
your high
number,
the
program
transfers
to
line
280.
If
the
secret
llumbcI
i~
uel
ween
yuur two
numbers
or equal to one of your numbers. the
program
continues.
These
statements
print
a
message
to
tell
you
where
the
secret
number
is in relation to your guesses.
Then
the
program
transfers
to line 180
to
allow you
to
guess
again.
If
you guessed the
secret
numher,
the
('flmpllter
tells
you
how
many
guesses
you took.
IlI-18
Examples:
;>NEW
;>100
REM
SECRET
NUMBER
;>110
RANDOMIZE
;>120
MSG1$="SECRET
NUMBER
IS"
;>130
MSG2$="¥OUR
TWO
NUMBERS"
;>140
CAll
CLEAR
>150
INPUT
"ENTER
LIMIT?
":L1
MIT
>160
SECRET~lNT(LIMIT~nND)+1
>170
CAll
CLEAR
>180
N=N+1
;>190
INPUT
"LOW.HIGH
GUESSES:
":LOII.HIGH
>200
IF
LOW<>HIGH
THEN
220
>210
l~
S~CR~T=LOW
THEN
3UO
>220 IF
SECRET<LOW
THEN
260
>230 IF
SECRET>HIGH
THEN
280
>240
PRINT
MSG1S&"
BETIJEEN":M
SG2$
;>250 GOTo
180
>260 PRINT MSGU!:"
LESS
THAN"
:MSG2$
>270
GOTo
180
>280 PRINT
MSG1S&"
LARGER
THA
N":MSG2$
>290
GOTo
180
>300 PRINT
"YOU
GUESSED
THE
S
ECRET"
>310 PRINT
"NUMBER
IN
";N;"TR
IES"
User's
Reference Guide

Other manuals for Texas Instruments TI-99/4A

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-99/4A and is the answer not in the manual?

Texas Instruments TI-99/4A Specifications

General IconGeneral
BrandTexas Instruments
ModelTI-99/4A
CategoryDesktop
LanguageEnglish

Related product manuals