If
C
is
greater than or equal to 10. the carry variable 0
is
incremented to 1
at
line 1070; otherwise it remai
ns
0:
1070
IF
C)=10
THEN
D;1
A
~
+B
~
C
llij]-15>=10-D~
or
A
~
+B
~
C
~
-3<10-D~(nochange)
o
will
be
either aor
1.
but
never greater than 1 because the maximum possi-
ble sum of any
two
single-digit numbers
is
18. thus the maximum tens value
that
can
be
carried over
is
1.
To prevent losing the carry in
D.
line 1040 resets the value of A to A + 0
on
the next loop iteration:
1040
A;A+D:I1=0
If
this statement were omitted. the carry
would
never
be
carried out. and the value
of A
would
be
incorrect.
When
0
is
added to
A.
0
is
reset to a in preparation for
the next loop iteration.
Step
4:
Link the individual
su
ms
(C)
and convert the total sum into a
string. Just as the augend and addend
were
entered
as
strings to avoid the
9-
digit length Iimit, the sums must be converted back into a string to avoid the
length Iimit again
du
ring
printing. This step converts the numbers back to string
form.
Line 1090 links the individual sums of C and converts the final answer back
into string form.
The
STR$(C)
function converts
Cinto
a one-digit string. The
RIGHT$
func-
tion extracts the rightmost N characters from
STR$(C).
N
is
set to 1 at line 1000 to
indicate
that
we
want
only the rightmost character to
be
extracted; the leftmost
character of C
is
unnecessary because
it
is
the sign value
("~"
if positive and
"-"
if negative) and
would
be
concatenated between each number of
C$
if
we
were
not to exclude it.
11::101::1
N=1
N[ill]
1060
C=A+:B
C~=A~+B~
1090
C$=RIGHT$(STR$(C).N)+C$
C$=RIGHT$(STR$(C}, 1
)+C$
C$=RIGHT$(!MlID.l
)+C$
C$=1êI + C$
194