Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 1 - Exercises - Page 39: 6

Answer

Replace Step 8 with Step $8^{*}$ : If $c_{m}=0,$ then print out the final answer $c_{m-1} c_{m-2} \ldots c_{0}$ otherwise, print out the final answer $c_{m} c_{m-1} c_{m-2} \ldots c_{0}$

Work Step by Step

The algorithm works perfectly except for Step $8 .$ That's the only step that may give us a final answer with a leading $0 .$ So instead let's replace that step with the following if $\ldots$ then $\ldots$ otherwise statement: $\begin{aligned} \text { Step } 8^{*} : & \text { If } c_{m}=0, \text { then print out the final answer } c_{m-1} c_{m-2} \ldots c_{0} \\ & \text { otherwise, print out the final answer } c_{m} c_{m-1} c_{m-2} \ldots c_{0} \end{aligned}$ ______________________________________________________ This new step will now check if the leading digit is a zero. If it is, then the printed answer will start at the next digit (skipped the leading zero). If not, then all digits are printed.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.