Share your repls and programming experiences

← Back to all posts
Large Integer
vincefearing (0)

In C++, the largest integer value is 2147483647. So an integer larger than this cannot be stored and processed as an integer. Similarly, if the sum or product of two positive integers is greater than 2147483647, the result will be incorrect.

One way to store and manipulate large integers is to store each individual digit of the number in an array. Design the following:

The class largeIntegers so that an object of this class can store an integer up to 50 digits long.
Appropriate constructors to initialize objects of the class largeIntegers.
Overload the operators + and – to add and subtract, respectively, the values of two objects of this class.
Overload the assignment operator to copy the value of a large integer into another large integer.
Overload the stream extraction and insertion operators for easy input and output.
If the input integer is larger than 50, set it to zero.
Have a loop asking for re-run the program.
(Hint: Read numbers as strings and store the digits of the number in the reverse order. Add instance variables to store the number of digits and the sign of the number.)

The program must have three files: largeIntegers.h, largeIntegers.cpp and largeIntegerMain.cpp