Radio Shack TRS-80 User Manual page 152

Micro computer system
Hide thumbs Also See for TRS-80:
Table of Contents

Advertisement

Logical Variations
This
next
program example mixes
equals
signs,
greater -than
and
less-than
in
the
same
pro-
gram.
It
determines and
reports
whether
the
two numbers you
input
are
both
positive,
both
negative, or
have
different
signs.
Analyze
the
program.
Note
the parentheses.
They
tell
you
to
shift
your
thinking
to "logi-
cal".
Type
it
in
and
RUN.
10
INPUT
"FIRST NUMBER IS"
;X
20
INPUT
"SECOND NUMBER IS"
;Y
30 IF
(X>=0)
*
(
Y>=0) THEN
70
40
IF
(X<0)
*
(Y<0)
THEN
90
50
PRINT "OPPOSITE SIGNS"
60
END
70
PRINT "BOTH POSITIVE
"
80
END
90
PRINT "BOTH NEGATIVE"
With Graphics Too, Yet
Yes, the
logical
symbols
also
work
along with the graphics statements. See
if
you
can
figure
out
the
surprise
caused
by
the
logical
OR
in line
40.
Type
this
program
in,
and
RUN.
10
CLS
20
FOR X=0 TD
127
30
FOR Y=0
TO 47
40
IF
CX>=64)
*
(Y>=24) THEN
60
50
SET
(X
t
Y)
60
NEXT
Y
70
NEXT
X
150

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents