Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 . ) Modify the following decimal addition algorithm. S O , that it does not print out non - sisnificant leading zeroes; that is

3.) Modify the following decimal addition algorithm. SO, that it does not print out non-sisnificant leading zeroes; that is, the answer would appear as 178 rather than 0178.
Figure 1.2 Algorithm for adding two m-digit numbers
1
Given: m1 and two positive numbers each containing m digits, am-1am-2dotsa4 and bn-1bn-2,b0
Wanted: cncn-1cn-2dotsc8 where (:bm-2,dotsbj}
Algorithm:
Step 1 Set the value of cany to 0
Step 2 Set the value of i to 0
Step 3 While the value of 1 is less than or equal to m=1, repeat the instruc: tions in Steps 4 through 6
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Add the two digits a, and b, to the current value of carry to get ci If c210, then reset c1 to (c3-10) and reset the value of carry to 1: otherwise, set the new value of carry to 0
Add 1 to l effectively moving one column to the left
Set cm to the value of carry
Print out the final answer, CmCm-1Cm-2dotsCS
Stop
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions