Question: Your program must implement the addition process as described in the Background section. Each number is to be stored in its own integer array, with


Your program must implement the addition process as described in the "Background" section. Each number is to be stored in its own integer array, with one digit per array element. The program should be able to add TWO numbers, with each number being up to 100 digits each. Get the first number from the user. Prompt the user to enter the number as TEXT and store it in a string. Verify that there are no more than 100 digits in the number. If invalid, print an error message and prompt again. Do this as many times as needed until the user enters a valid number. Extract the digit characters from the string and store them as consecutive numeric digits in an integer array. Think about how you want to arrange the digits in the array. Should you store them in the same order as the original string? What about in reverse order? Should the digits be stored starting at the "left" end or "right" end of the array? Get the second number from the user. Prompt for the second number, store it as a string, and validate it. Extract the digit characters from the string and store them in another integer array. Using the column addition procedure, find the sum of the two numbers. You are allowed to create and use a third integer array to hold the digits of the sum. When processing each column, display the digits being accessed and their current sum. (Review the "Sample Run" section for examples of what it should look like.) Display the original two numbers and their final sum to the console. After displaying the sum, ask the user whether to enter another set of numbers (in which case the program should start again at Step 1) or to quit. You are required to write at least two (2) functions of your own and call them from your main program. Make one of the functions print the digits of a numeric array. The array and the amount of digits should be passed to it as arguments. For the second function, choose something in your main program that makes sense to separate out into its own function (e.g., long or complicated or needs to be done several times). Consider carefully what arguments it needs and what it returns. In the C language, it is trivial to add together two variables that contain integer values, as long as the data type is large enough to represent the numbers and their sum. For example, a 32-bit variable supports integers up to ten digits. With 64 bits, the number of digits is twenty. For most applications, this is more than sufficient. However, what if you wanted to add two integers that had 25 digits? Or 1000 digits? Clearly, storing the values in standard variables would not work. Your task is to add two integer numbers that can have an arbitrarily large number of digits. A simple way to perform addition is to use the method taught to children. You align the columns of each number (starting with the one's place) and add the individual digits within each column, being sure to account for the "carry", if any, from a previous summation. What is the value of 35 + 28? (Answer: 63) What is the value of 1500 + 21 ? (Answer: 1521) What is the value of 9908 + 4252? (Answer: 14160)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
