EasyManua.ls Logo

Radio Shack TRS-80

Radio Shack TRS-80
236 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
Loading...
Chapter
5
Using
(
)
and the Order of
Operations
Parentheses
play an important role in computer programming,
just as in ordinary math.
They are
used here in the same general
way, but there
are
important exceptions.
l.In
BASIC, parentheses can enclose
operations to
be performed. Those
operations
which are
within parentheses
are
performed
before
those not in
parentheses.
2.
Operations buried deepest within parentheses (that is,
parentheses
inside parentheses)
are
performed first.
3. When there is a
"tie"
as to
which
operations
the Computer should perform first after
it
has removed all parentheses, it works its way along the program line from left
to
right
doing
the multiplication and division. It then starts
at
the left
again and per-
forms the addition and
subtraction.
NOTE:
INT. RND and ABS functions are performed
before multiplication and division.
(We
haven't
talked about these yet, but just to be complete
. . .
)
4. A. problem listed as (X) (Y) will NOT tell
the Computer
to multiply. X
*
Y is for
multiplication.
Example:
To
convert temperature in Fahrenheit to Celsius (Centigrade),
the following
relationship
is
used:
The Fahrenheit
temperature equals
32
degrees plus nine-fifths of the
Celsius
tempera-
ture.
Or,
maybe you're
more used to the simple formula
=
I-
X C
+
32
Assume
we have a
Celsius
temperature of
25°.
Type in this program and
RUN
it.
10 REM
*
CELSIUS
TG
FAHRENHEIT CONVERSION
*
20
C
=
25
30 f
=
(
9/5
)*C
+
32
40 PRINT
C;
"DEGREES
CELSIUS
="
;
F
;"
DEGREES
FAHRENHE
I T .
"
"FRIENDS."
If
you
want to
be
sure
your problems
are
calcu-
lated cotreetJJr,
iuse
(
)
around
operations you
:
;*ant:p£rf/0ri»e&:fEif$L
ItecaH th«
old memory aid,
"l#y
Dear
Aunt
y%-.
.Srtly'*?
In
math
you
are supposed
to do
Multipli-
cation
and
Division first (from
left
to righ i)
,
then
comeback
for Addition and
Subtraction
(left to
:-^\:;";r
--'
:
.;^. :SS?M^°
-
"
^
:
'-}\.
25

Other manuals for Radio Shack TRS-80

Related product manuals