***MULTIPLE
IHTEGER
ADDITIOH***
?1234567890123456
'7'57943572
AHSWER=
1234567948067028
SUBTRACTION
As
with
addition, there are
two
methods of subtraction. The first
method uses numeric strings by converting the input strings to numeric con-
stants, then back to strings for printing. The second uses multiple integer
math.
Method 1: Subtraction via Numeric Strings
This subtraction program contains many sections of the
"Addition
via
Numeric Strings" (page 190) program
with
a few changes. The steps involved are
as
follows:
1.
Input
the minuend and subtrahend
as
two
positive numeric strings.
2.
Right
justify
the strings.
3.
Determine the larger numeric string.
4.
Subtract
corresponding digits of the strings separately
with
borrowed
carries.
5.
Concatenate the answer
into
a one-string result.
6.
Eliminate leading zeros in the answer string.
7.
Print the answer string.
At
the end of this section
is
a complete listing
of
the sample program to
be
used
as
demonstration.
Step 1: The first step
is
to
input the minuend and subtrahend
as
two
posi-
tive numeric strings using an INPUT statement:
Screen Display
10
PRIHT"***SUBTRACTIOH***":PRIHT
20
IHPlIT
A$,B$
RUH
?123456789012
??57943572
Memory Contents
A$1112131
4
151eJ7181910J1121
8$15171914131517121
A$
is
the minuend (the first or top number entered. from
which
another number
is
subtracted). B$
is
the subtrahend {the number subtracted from the minuendl.
202