Sharp PC-1500A Instruction Manual page 24

Hide thumbs Also See for PC-1500A:
Table of Contents

Advertisement

All
and
more
about Sharp
PC-1500
at
http://www.PC-1500.info
Now the
General
calculates the
actual
purchase
p rice at the
PX:
G
-
(G*
.10
)
+
8
IENTEAI
DCC
RUM
I
l
1
:
1
.:::
C1C1~
1_11_1
!"_. ·-·
-
·
and the purchase
price at Discount
Bernie's:
G
-
(G*
.05)
l•HT••I
DCC
RUN
Clearly, Discount
Oer1'lie's
has the better barga in.
(Clever
readers
may
have
noticed that
the
General
could
have
worked this problem using SHARP's unique recall
featu
re (see Chapter
2), though not Quite as easily)
.
There are severa
I
lessons to be learned
from
the preceed ing example
.
.
.
Observe that the General's first calcu lation had the following fo rm:
variable-name
=
expression
An instruction w ith this
form
is known as an Assignment Statement.
It is important not to
confuse an Assignment statement with an inequality.
Unlike
Assignment statements, inequalities
are not
used separately, but form parts
of
other programming
instructions.
The Assignment statement
instructs
SHARP to store the
result,
obtained by
calculating
the
expression, in the
memory
location associated w
:
i
th the
given
variable
name.
T hereafter,
using
the name of
the
variable (G in our example)
is
juot
like
using the
result
itself. Notice also
that
a
variable may be used as many times as needed
in
the same calculation.
Variables
can
be used fo
r
other neat tricks,
too.
The value of one variable
can be
assigned to
another.
as in the statement:
H
=
G
which will copy
our
previous result into H.
G
has not been altered;
the
same result is now stored
in two (iifferent
variables.
Variables which hold numbers can be incremented
or
decremented in one statement as in this
example:
G
=
G
+
S
This
instruction
will cause SHARP to recall the value of
G,
add
5 to that value, and
store
the
new value back into G. This capability is useful for all
kinds
of
calculations:
2·2
Do not sale this PDF
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents