Question: The following program segment is an attempt to compute the quotient (forgetting any remainder) of two positive integers ( a dividend and a divisor) by
The following program segment is an attempt to compute the quotient (forgetting any remainder) of two positive integers ( a dividend and a divisor) by counting the number of times the divisor can be subtracted from the dividend before what is left becomes less than the divisor. For instance 7/3 should produce 2 becuase 3 can be subtracted from 7 twice. Is the program correct?
count = 0
Remainder = dividend
repeat:
Remainder = Dividend - Divisor
Count = Count + 1
until (Remainder < Divisor)
Quotient = Count.
implement the program in Python
How would you correct this code?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
