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 (count
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
