Question: In C++ an unsigned int data type can save 4 bytes. If all four bytes are being used for its value (i.e. this is an
- In C++ an unsigned int data type can save 4 bytes. If all four bytes are being used for its value (i.e. this is an unsigned integer) then you have 8 * 4 = 32 bits, so your range is from 0 to 2^32 (0 - 4,294,967,295). If we conclude the above statement, the maximum range for storing an unsigned int is 4,294,967,295 i.e. upto 10 digits. If any number larger than that is saved it will result in truncation. Create a class hugeInteger that uses a N-element array of digits to store integers as large as Ndigits. Choose appropriate properties. Provide member functions:
- Default constructor
- Parameterized constructor
- Copy Constructor
- Destructor
- Input (take 20 values for 20 array locations from user. Each location can only contain 0-9 )
- Output (cout the whole array i.e. 20 digit integer)
- Add ( to assdd a hugeInteger type variable provided as an input and returns the sum as another hugeInteger)
- isZero (return 1 if the number is zero, return 0 if number is non-zero)
- isEqualTo (compare two hugeIntegers)
- isGreaterThan (compare two hugeIntegers)
- Above two function takes one huge integer type variable as an argument and returns true if the condition is satisfied and false otherwise
- There should be no memory leakage, shallow copies and bad pointers
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
