Question: 3 . ) Modify the following decimal addition algorithm. S O , that it does not print out non - sisnificant leading zeroes; that is

3.) Modify the following decimal addition algorithm. SO, that it does not print out non-sisnificant leading zeroes; that is, the answer would appear as 178 rather than 0178.
Figure 1.2 Algorithm for adding two m-digit numbers
1
Given: m1 and two positive numbers each containing m digits, am-1am-2dotsa4 and bn-1bn-2,b0
Wanted: cncn-1cn-2dotsc8 where (:bm-2,dotsbj}
Algorithm:
Step 1 Set the value of cany to 0
Step 2 Set the value of i to 0
Step 3 While the value of 1 is less than or equal to m=1, repeat the instruc: tions in Steps 4 through 6
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Add the two digits a, and b, to the current value of carry to get ci If c210, then reset c1 to (c3-10) and reset the value of carry to 1: otherwise, set the new value of carry to 0
Add 1 to l effectively moving one column to the left
Set cm to the value of carry
Print out the final answer, CmCm-1Cm-2dotsCS
Stop
 3.) Modify the following decimal addition algorithm. SO, that it does

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!