Answer to Question #312160 in C++ for cobet

Question #312160

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 because 3 can be subtracted from 7 twice. Is the program correct? Justify your answer.


Count ← 0;


Remainder ← Dividend;


repeat (Remainder ← Remainder – Divisor;


Count ← Count + 1)


until (Remainder < Divisor)


Quotient ← Count.

1
Expert's answer
2022-03-15T12:59:59-0400

Here is program:

int main()
{
	int Quotient;
	int Count;
	int Remainder;
	int Divisor;
	cin >> Quotient;
	cin >> Divisor;
	Count = Quotient / Divisor;
	Remainder = Quotient % Divisor;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment