The same answer appears for each example as soon as you press
L.B..@Jiii).
The spacing in math problems is unimportant to the com-
puter.
Tryout
problems of your own. Make long problems that com-
bine subtraction and addition functions.
The multiplication
sign-the
asterisk
(*)-is
located
on
the Right
Arrow key
[J
. The division sign
is
the slash
(I)
on
the Question Mark
key
IT] . Type the following statements:
PRINT
2 * 2
PRINT
(2*2)
PRINT
6 / 3
PRINT
(6/3)
The computer not only understands the use of parentheses
in
math
problems but needs them when the problems become complex. Notice
what happens
in
this problem with and without parentheses:
PRINT
3*
(2+2)
PRINT
3*2+2
The answer to the first problem
is
12; the answer to the second prob-
lem
is
8.
In
the first problem, the computer first adds 2 and
2,
then
multiplies by 3 to arrive at 12.
In
the second problem, the computer
multiplies 3 and 2 first, then adds 2 to arrive at 8. Whenever the com-
puter encounters parentheses
in
a math problem, it does the computa-
tions inside the parentheses first and then finishes the rest of the
calculations.
Tryout
the problems below to discover some other interesting facts
about how your computer works. See if you can predict the answers
before you press I Return
I:
PRINT
(2+2)*3
PRINT
2+2*3
In
the first problem, the computer does the computation inside the
parentheses first.
In
the second problem, the computer does the
multiplication first, then the addition. The computer executes these
mathematical functions according to rules of order: first, computations
inside parentheses; second, exponential functions; third, multiplication
and division functions as they appear
in
the problem from left to right;
and last, addition and subtraction functions from left to right. The rules
are summarized
in
the following table:
49