#include
using namespace std;
int main() {
int i,j,k,m,n,d,e=0;
cin>>m;
int a[m];
for(i=0;i<m;i++)
cin>>a[i];
cin>>n;
int b[n];
k=max(n,m);
int c[k];
for(i=0;i<n;i++)
cin>>b[i];
for(i=n-1,j=m-1;;i–,j–)
{
d=a[j]+b[i]+e;
c[k-1]=d%10;
e=d/10;
k–;
if(i<=0)
{
i=1;
b[0]=0;
}
if(j<=0)
{
j=1;
a[0]=0;
}
if(k<=0)
{
break;
}
}
for(i=0;i<max(m,n);i++)
cout<<c[i]<<", ";
cout<<“END”;
return 0;
}
2 test passed and two failed
hello @anujsharmabadboy
test ur code for test case->
4
9 9 9 9
4
9 9 9 9
output should be
1 9 9 9 8
but urs is giving
9 9 9 8
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
make seperate doubt threads for each
u`ll query will be answered
yes, i have already created doubt thread for those
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
already submitted …