Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+8. How have your enablers changed within the last three years?

Answered: 1 week ago

Question

2. List the advantages of listening well

Answered: 1 week ago