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

3.) Modify the following decimal addition algorithm. So, that it does not print out non-significant leading zeroes; that is, the answer would appear as 178 rather than 0178.
Figure 1.2 Algorithm for adding two m-digit numbers
Given: m1 and two positive numbers each containing m digits, am-1*am-2dotsa0 and bm-1bm-2dotsb0
Wanted: cmcm-1cm-2dotsc0, where bm-2dotsb0
Algorithm:
Step 1 Set the value of carry to 0
Step 2 Set the value of i to 0
Step 3 While the value of i is less than or equal to m-1, repeat the instructions in Steps 4 through 6
Step 4 Add the two digits ai and bi to the current value of carry to get ci
Step 5 If c110, then reset c1 to (c1-10) and reset the value of carry to 1: otherwise, set the new value of carry to 0
Step 6 Add 1 to 1, effectively moving one column to the left
Step 7 Set cm to the value of carry
Step 8 Print out the final answer, cmcm-1cm-2cdots0
Step 9 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!