1.

Construct an iterative algorithm to compute the quotient and remainder after dividing an integer A by another integer B.

Answer»

divide (A, B)

– – inputs: A is an integer and B ≠ 0

– – Outputs: q and r such that A = q x B + r and 0 < r < B

q : = 0, A

While r ≥ B

q, r : = q + 1, r – B



Discussion

No Comment Found