Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please use the c++, finish the code CS 23001 Spring 2017 Page 3 of 5 M. Decker 5

ID: 3588858 • Letter: P

Question

please use the c++, finish the code

CS 23001 Spring 2017 Page 3 of 5 M. Decker 5. (25pts) For the bigint class as in Project 1 implement the two methods below. The first is gint numbers and returns the result. The the constructor that takes a character string literal (of character digits) and converts it into a specifications of these are given below. You MUST use the following representation. Each digit of bigint is in one element of the digit integer array. The 10 digit is stored in digitiol, the 10 digit is stored in digit[1], and so on. Thus, the number 299,793 is stored as below in digit with leading zeros (see implemented default constructor). digit[i] 0 0. 0 2 9 9 7 9 3 99 98.. 6 5 4 3 2 1O const int CAP = 100; class bigint f private: int digit[CAP]; public: bigint () { for (int i = 0; i

Explanation / Answer

Below is your code ;-

/**

biginteger implementation

*/

#include "conio.h"

#include "iostream"

using namespace std;

const int CAP = 100;

class bigint{

int digit[CAP];

public:

bigint();

bigint(const char[]);

bigint operator+ (const bigint&) const;

};

bigint::bigint(){

for(int i=0; i< CAP; i++){

digit[i]=0;

}

}

bigint::bigint(const char num[]){

int i = 0;

for(int i=0; i< CAP; i++){

digit[i]=0;

}

i =0;

while(num[i]!= ''){

++i;

}

--i;

int j = 0;

while(i>=0){

digit[j]= num[i] - '0';

j++;

i--;

}

}

bigint bigint::operator +(const bigint &a) const{

bigint temp;

int num = 0;

int carry = 0;

for(int i = 0; i < CAP; i++)

{

num = digit[i] + a.digit[i] + carry;

if(num >= 10)

{

num = num - 10;

carry = 1;

}

temp.digit[i] = num;

}

  

return temp;

}