Question: Chapter 1 Exercises: Modify the decimal addition algorithm of Figure 1 . 2 so that the two numbers being added need not have the same

Chapter 1 Exercises:
Modify the decimal addition algorithm of Figure 1.2 so that the two numbers being added need
not have the same number of digits. That is, the algorithm should be able to add a value a containing
m digits to a value b containing n digits, where m may or may not be equal to n.
The following is Euclid's 2,300-year-old algorithm for finding the greatest common divisor of
two positive integers I and J.
a. Go through this algorithm using the input values 20 and 32. After each step of the algorithm
is completed, give the values of I, J, and R. Determine the final output of the algorithm.
b. Does the algorithm work correctly when the two inputs are 0 and 32? Describe exactly what
happens, and modify the algorithm so that it gives an appropriate error message.

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!