Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- My numbers are 23 and 45. M I Ai Bi Carry Ci
- Step 1: Set Carry equal to 0 2 0
- Step 2: Set i equal to 0 2 0 3 5 0
- Step 3: For each i less than or equal to m - 1, repeat steps 4-6 2 0 3 5 0
- Step 4: Add the two digits ai and bi to the current value of carry to get ci 2 0 3 5 0 8
- Step 5: If ci is greater than or equal to 10 reset ci to ( ci - 10 ) 2 0 3 5 0 8
- and reset the value of carry to 1 otherwise set the new value of carry to 0
- Step 6: Add 1 to the value of i 2 1 2 4 0 0
- Step 4: Add Ai and Bi to carry to get Ci 2 1 2 4 0 6
- Step 5: If Ci is greater than or equal to 10 reset Ci to (Ci-10) 2 1 2 4 0 6
- and reset the value of carry to 1 otherwise set the new value of carry to 0
- Step 6: Add 1 to the value of 1 2 2 0 0 0 0
- Step 7: Set the value of cm to the value of carry 2 2 0 0 0 0
- Step 8: Print out the value of Cm, Cm-1, Cm-2...C0 2 2 0 0 0 0
- Step 9: Stop
- Final answer: 23 + 45 = 68
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement