Download Print this page

Commodore 64 User Manual page 43

Hide thumbs Also See for COMMODORE 64:

Advertisement

When used in a series of arithmetic calcula
tions, parentheses tell your computer which
numbers to evaluate first, if you don't want it
to take each number from left to right in
order. For instance, type the following calcula
tion but do not press RETURN yet:
?I2-5*(2
f30-2*5)
Check your screen to be sure that you have
typed the calculation exactly as it is printed
above.
SCREEN 1
Your computer will first calculate
2 + 3 and multiply this sum by 5, then multi
ply 2 times 5 and subtract that from 30. Next
it will subtract the first calculation from 12,
and finally add that total to the second
calculation.
Without the parentheses, the answer would
be 25. With the parentheses, the answer
should be 7. Press the RETURN key now, and
what do you get?
?12-5*(2 + 3)
7
READY.
[30-2*5]
As you can see, the computer has chosen the
correct answer, 7.
SCREEN 2
Before going on to the next exercise, clear
the screen by holding down a SHIFT key and
pressing the CLR/HOME key.
USING NUMBERS WITH COMMANDS
Whenever you create a program on your com
puter, you begin each command with its own,
unique number. The computer will obey each
command in your program in numerical order,
based on these numbers. When you precede a
command line with a number, pressing
RETURN will not execute the command
immediately. Instead, you must type the word
RUN to instruct the computer to perform
all the command lines in your program, in
numerical order.
■':' * - ."
■ e -2*s>m
SCREEN 1
Parentheses used In equations tell the
computer which numbers to calculate first.
iPR I ft T
CHI' X ■.
1 -1 v
3> +(30-2*5)
SCREEN 2
The computer performs the calculations and
displays the answer.
41

Advertisement

loading

Related Products for Commodore COMMODORE 64

This manual is also suitable for:

Vic 20