Question
The code needs to be c++ Write a program that reads two positive integers that are of arbitrary length and then outputs the sum of
The code needs to be c++
Write a program that reads two positive integers that are of arbitrary length and then outputs the sum of the two numbers. Your program will read the digits as values of type char so that the number 1234 is read as the four characters '1', '2', '3', and '4'. As the characters are read they are changed to values of type int and stored in a list. (Now you can see the first reason why storing the digits backwards has an advantage.) After the first number has been read your program reads the second number, storing it in a second list.
Your program will perform the addition by implementing the usual paper-and-pencil addition algorithm. (Now you should discover the second reason why storing the digits backwards is advantageous.) The result of the addition is stored in a list and the result is then written to the screen. Include a loop that allows the user to continue to do more additions until the user says the program should end.
Of course, your multiple precision addition code should be formulated as a function that accepts a pair of lists, returning a list as its result (the sum of the two inputs).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started