Question: 1.Correct the logic/syntax error in the code below to produce the correct output, WITHOUT CHANGING ITS FLOW. 2. Explain in detail the reason/concept behind error.

1.Correct the logic/syntax error in the code below to produce the correct output, WITHOUT CHANGING ITS FLOW.

2. Explain in detail the reason/concept behind error.

1.Correct the logic/syntax error in the code below to produce the correct

Code without template works perfectly fine, here is the output without templates:

output, WITHOUT CHANGING ITS FLOW. 2. Explain in detail the reason/concept behind

DO NOT CHANGE THE FLOW OF THE PROGRAM.

Code for reference:

# include

using namespace std;

template

class HugeInt{

public:

int i;

int sum;

T arr[20];

void setArray(){

for(i=0;i

cin>>arr[i];

}}

void s(T&x, T&y){//CHECK

int c=0;

T res;

for (i = 0; i

{

if(i==19){

res.arr[i]=x.arr[i]+y.arr[i]+c;

}

else {res.arr[i]=(x.arr[i]+y.arr[i]+c)%10;}

c=(x.arr[i]+y.arr[i])/10;

}

for (i = 19; i >=0; i--)

{

cout

}

}

};

int main(){

HugeInt x,y,res;

cout

x.setArray();

cout

y.setArray();

res.s(x,y);

return 0;

}

112345678912345678912ENTERSECOND20DIGITINTEGER

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!