Question: In most personal computers, the largest integer is 32,767 and the largest long integer is 2,147,483,647. Some applications, such as the national debt, may require
In most personal computers, the largest integer is 32,767 and the largest long integer is 2,147,483,647. Some applications, such as the national debt, may require an unbounded integer. One way to store and manipulate integers of unlimited size is by using a linked list. Each digit is stored in a node of the list.
To add two numbers, we simple add the corresponding digit in the same location in their respective linked lists with the carry from the previous addition. With each addition, if the sum is greater than 10, we need to subtract 10 and set the carry to 1. Otherwise, the carry is set to 0.
Write a program that can add two integer-linked lists. Design your solution so that the same logic adds the first numbers (units position) as well as the rest of the number. In other words, do not have special one-time logic for adding the units position.
You need to write a class for the integer-linked list. Name it: IntList. You also need a class that can hold two integer-linked lists and also includes a method to add them. Name this 2nd class: HugeInt. The method to add should be named: add.
The corresponding files should be named with the class name and a .h or .cpp extension as appropriate.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
