c++ Program
You are required to add two numbers of 5 digits each using Stack and Queue. You may follow thefollowing 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 theirlast 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 ofnext 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.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here