Problem Statement
The int basic data type provided by the C/C++ language to represent
integers has the following limitations, viz., the size of the data
type is machine dependent and also is limited in the smallest and
largest integer that it can represent.
In this assignment you have to implement a class BigInt, which allows
a programmer to declare and use integers of arbitrary length. You have
to support basic arithmetic operations and relational operations
objects of this data type. You should also be able to read and write
BigInts from and to stdin and stdout respectively.
A programmer should be able to use BigInt in a C++ program just like
the type int as given in the example below:
Program
#include <iostream.h>
#include "BigInt.h"
#define SIZE 5
BigInt big_array[SIZE], minint, maxint;
int main() {
BigInt sum(0); // Constructor with integer parameter
BigInt product("1"); // Constructor with string
int i ;
for (i=0; i<SIZE; i++) {
cin >> big_array[i]; // read BIGINT from stdin
if (0==i) {
maxint = big_array[i]); // assignment
minint = big_array[i]);
}
else {
if (maxint < big_array[i]) // relational operation
maxint = big_array[i]);
else if (minint > big_array[i])
minint = big_array[i]);
}
}
sum = maxint + minint;
product = big_array[1] * big_array[4];
cout << sum << endl ;
cout << maxint - minint << endl ;
cout << product << endl ;
cout << big_array[3] / big_array[0] << endl ;
cout << big_array[3] % big_array[0] << endl ;
}
Sample Input:
102378650387630 14 -19876543920 202378650387630 -2134
Sample output:
202358773843710
-202398526931550
-29876
1
100000000000000
Features to be provided by your BigInt implementation
1. Your implementation of BigInt should provide the following
functionality:
a. Constructors to be provided
BigInt( )
BigInt (int)
BigInt (char *)
BigInt (BigInt &) - copy constructor
b. Overload operators
<<
=
+
-
*
/
%
< <==
==
2. BigInts will have digits <= 100.
Deliverables:
Code: You must submit the following files: 1. BigInt.h (containing the
function declarations) 2. BigInt.c (containing the function
definitions - it should not contain any main)
Assessment: Your code will be tested with test programs similar to the
above program