Question: Trace through the decimal addition algorithm of Figure 1.2 using the following input values: m = 3 a 2 = 1 a 1 = 4
Trace through the decimal addition algorithm of Figure 1.2 using the following input values:
m = 3 a 2 = 1 a 1 = 4 a 0 = 9
b 2 = 0 b 1 = 2 b 0 = 9
At each step, show the values for c 3, c 2, c 1, c 0, and carry.
FIGURE 1.2 Given: m> 1 and two positive numbers each containing m digits, a b6-.b, Wanted: CC C 9...G where c-1 Cm-2 = (a , m-1 a, and m-9 a) + (b_b. Algorithm: Step 1 Set the value of carry to 0 Step 2 Set the value of i to 0 While the value of i is less than or equal tom 1, repeat the instructions in Steps 4 through 6 Step 3 Step 4 Add the two digits a, and b, to the current value of carry to get c, If c, = 10, then reset c, to (c - 10) and reset the value of carry to 1; otherwise, set the new value of carry to 0 Add 1 to i, effectively moving one column to the left Step 5 Step 6 Step 7 Set c to the value of carry Print out the final answer, cC-1 Cm-o Step 8 Step 9 Stop Algorithm for adding two m-digit numbers
Step by Step Solution
3.37 Rating (147 Votes )
There are 3 Steps involved in it
Answer Step 1 Tracing decimal addition algorithm with input values Step 2 Algorithm An algorithm is a stepbystep and ordered sequence of instruction p... View full answer
Get step-by-step solutions from verified subject matter experts
