Question
For C++ without string Write a program for the following: Assume that your computer has the very limited capability of being able to read and
For C++ without string
Write a program for the following: Assume that your computer has the very limited capability of being able to read and write only single-integer digits and to add two integers consisting of one decimal digit each. Write a program that can read two integers up to 50 digits each, add these integers together, and display the result. Test your program using pairs of numbers of varying lengths including one exceeding 50 digits. Hint: Store the two numbers in two int arrays of size 50, one digit per array element. If the number is less than 50 digits in length, enter enough leading zeros (to the left of the number) to make the number 50 digits long. You will need a loop to add the digits in corresponding array elements. Dont forget to handle the carry digit if there is one! Make sure you test your program with enough test data. Hint: Digits from the large integer values should be read in as characters and then converted to integers one character at a time to be stored in the 51 element integer array. Since the number is large and you cannot input it as an integer. MAKE SURE YOU CHECK FOR OVERFLOW IF SUM IS MORE THAN 50 DIGITS. TO CHECK THESE THE TWO NUMBERS MUST BE 50 DIGITS LONG AND THE SUM IS 51 DIGITS LONG.
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