Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

How streamlined is this process? Goal: Compute for the product of two positive integers using the addition operation only.

OpenStudy (anonymous):

Step 1: Request the first and second positive integers. Call them FirstNum and SecondNum, respectively. Step 2: Compare FirstNum with SecondNum. Call the lesser positive integer TotalCount; the greater positive integer, Term. Step 3: Set Sum to 0. Let Sum be the final answer to the addition operation. Step 4: Add Term to Sum. Step 5: Count the number of instances of Term in Sum. Call this CurrentCount. Step 6: Repeat Steps 4-5 until CurrentCount is equal to TotalCount. Step 7: Display Sum.

OpenStudy (asnaseer):

looks good to me instead of CurrentCount, you could just decrement TotalCount and stop once this hits zero.

OpenStudy (anonymous):

By decrementing CurrentCount, do you mean subtracting from TotalCount after each time Step 4 is completed? How would this be more efficient than the current process?

OpenStudy (asnaseer):

It is only marginally more efficient in that it saves you declaring another variable. So after Step 4 you would do something like: TotalCount = TotalCount - 1

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!