Ask Question
18 June, 12:16

The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of X copies of Y; that is, 3 times 4 is computed by accumulating the sum of three 4s.

Is the program segment correct? Explain your answer.

Product ←0;

Count ←0;

repeat (Product ←Product + Y,

Count ←Count + 1)

until (Count = X)

+2
Answers (1)
  1. 18 June, 13:30
    0
    The program is correct: at the beginning, product = 0. Then, we start summing Y to that variable, and we sum Y exactly X times, because with each iteration we increase Count by 1, and check if Count=X so that we can exit the loop.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of X copies of ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers