Information Technology Reference
In-Depth Information
Figure 1.1.
Adding two single-digit numbers
Procedure PROC0:
You are given two digits as input and will return two digits as output.
To do so, use this table.
0123456789
0
00 01 02 03 04 05 06 07 08 09
1
01 02 03 04 05 06 07 08 09 10
2
02 03 04 05 06 07 08 09 10 11
3
03 04 05 06 07 08 09 10 11 12
4
04 05 06 07 08 09 10 11 12 13
5
05 06 07 08 09 10 11 12 13 14
6
06 07 08 09 10 11 12 13 14 15
7
07 08 09 10 11 12 13 14 15 16
8
08 09 10 11 12 13 14 15 16 17
9
09 10 11 12 13 14 15 16 17 18
To add the two digits, find the row for the first digit in the table, and find the
column for the second digit, and return as output the two digits that appear at
their intersection in the table.
These are the kinds of detailed instructions one wants in a procedure.
PROC0
Maybe the simplest job in arithmetic, the one learned before any others, is the addition
of two single-digit numbers. Figure 1.1 shows a procedure called PROC0 that gives
explicit instructions for adding two digits.
Notice that it makes use of an addition table . (Typically, young children are not
taught addition in this way, but most of us were taught multiplication using a table
like this, which we had to memorize.) One can see that if PROC0 is called on 7 and 6 ,
it will return 13 , and if it is called on 3 and 5 , it will return 08 . (It will be handy for
the answer returned here to be the two digits 08 and not simply 8 .)
 
Search WWH ::




Custom Search