Question
Using Figure 2.10 for multiplying of nonnegative values as a guide, write an algorithm to divide nonnegative values via repeated subtraction. Use a similar notation
Using Figure 2.10 for multiplying of nonnegative values as a guide, write an algorithm to divide nonnegative values via repeated subtraction. Use a similar notation as in Figure 2.10 modified, of course, to do division. In addition, do a trace for 67 divided by 15.Division by subtraction is straightforward. For example, 33 divided by 9 would proceed as follows.33 9 = 2424 9 = 1515 9 = 6So, 33 divided by 9 is 3 with a remainder of 6. The algorithm is to input values for a andb and then divide a by b. Both the quotient and remainder are to be output.The algorithm and trace must be typed.
Figure 2.10 Algorithm for multiplication of nonnegative values via repeated addition Get values for a and b If (either a 0 or b- 0) then Set the value of product to 0 Else Set the value of count to 0 Set the value of product to 0 While (countStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started