Question: Algorithm for adding two m-digit numbers: Assume the algorithm is called with the following inputs: a = 73, b = 42. (i) Determine the value

Algorithm for adding two m-digit numbers:

Algorithm for adding two m-digit numbers: Assume the algorithm is called with

Assume the algorithm is called with the following inputs: a = 73, b = 42.

(i) Determine the value of m. Show all work.

(ii) What is the largest number that can be represented with this value of m? Show all work.

(iii) What are the values of ai and bi that will be used in the algorithm?

(iv) What is the continuation condition of the loop in the above algorithm? Write the pseudocode as it appears above.

(v) Trace through the m-digit addition algorithm, step-by-step.

FIGURE 1.2 Given: m1 and two positive numbers each containina m digits, a a and bm2.bo Wanted: cm Cm1 Cm 2... Co, where Cm C-1 Cm2. . Co a, m- m-2 Algorithm: Step 1 Set the value of carry to 0 Step 2 Set the value of i to O Step 3 While the value of i is less than or equal to m - 1, repeat the instruc- tions in Steps 4 through 6 Step 4 Step 5 Add the two digits a, and b, to the current value of carry to get c If c z 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 6 Step 7 Step 8 Step 9 Set cm to the value of carry Print out the final answer, Cm Cm-1 Cm-2 Stop Co FIGURE 1.2 Given: m1 and two positive numbers each containina m digits, a a and bm2.bo Wanted: cm Cm1 Cm 2... Co, where Cm C-1 Cm2. . Co a, m- m-2 Algorithm: Step 1 Set the value of carry to 0 Step 2 Set the value of i to O Step 3 While the value of i is less than or equal to m - 1, repeat the instruc- tions in Steps 4 through 6 Step 4 Step 5 Add the two digits a, and b, to the current value of carry to get c If c z 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 6 Step 7 Step 8 Step 9 Set cm to the value of carry Print out the final answer, Cm Cm-1 Cm-2 Stop Co

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!