c++ Program You are required to add two numbers of 5 digits each using Stack and Queue. You may follow the following steps to solve this problem unless you can think of a better method! 1. Separate...


c++ Program


You are required to add two numbers of 5 digits each using Stack and Queue. You may follow the
following steps to solve this problem unless you can think of a better method!
1. Separate the digits of each number and insert them into two separate queues starting from their
last digits.
2. Dequeue one number each from the two queues.
3. Add them.
4. Divide the sum by 10.
5. Push the remainder into a Stack and the Quotient (i.e., carry) would be added to the sum of
next two numbers.
6. Repeat Steps 2 – 5 until both queues are empty.
7. Pop all elements of the Stack one by one and push them onto a new Stack.
8. Print the new Stack. It will be the sum of the two 10-digit numbers.



Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here