Combining Things - Commodore 64 User Manual

Hide thumbs Also See for Commodore 64:
Table of Contents

Advertisement

you will get 35 divided by 5 with 2 added to the answer, which is not
what you intended at all. To get what you really wanted,
try this:
?
35
/
(5
+ 2)
~ . ,
What happens now is that the computer evaluates what is contained
in the parentheses
flrst. If there are parentheses
within parentheses,
the
innermost parentheses
are evaluated
flrst.
Where there are a number of parentheses
on a line, such as:
? (i2
+ 9)
.
(6 + 1)
147
the computer evaluates them left to right. Here 21 would be multiplied
by 7 for the result of 147.
COMBINING THINGS
Even though we've spent a lot of time in areas that might not seem
very important,
the details presented
here will make more sense once
you start to program,
and will prove invaluable.
To give you an idea how things flt in place, consider the following:
how could you combine the two types of print statements
we've exam-
ined so far to print something more meaningful on the screen?
We know that by enclosing something within quote marks prints that
information on the screen exactly as it was entered,
and by using math
operators,
calculations can be performed.
So why not combine the two
types of PRINT statements
like this:
SEMICOLON MEANS NO SPACE.
?
115
:+: 9
:;::; II::
5
:« 9
5
;t :3 =
45
28

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents