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

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!