Sum of two arrays

my code is failing two testcases.
here’s my code
#include<bits/stdc++.h>

using namespace std;

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cin>>m;
int b[m];
for(int i=0;i<m;i++)
cin>>b[i];
vector c;
reverse(a,a+n);
reverse(b,b+m);
int minm=min(n,m);
int carry=0;
for(int i=0;i<minm;i++)
{
int sum=a[i]+b[i]+carry;
if(sum>9)
{
c.push_back(sum%10);
carry=sum/10;
}
else
{
c.push_back(sum);
carry=0;
}
}
if(minm==n)
{
for(int i=n;i<m;i++)
{
if(carry!=0)
{
c.push_back(b[i]+carry);
carry=0;
}
else
c.push_back(b[i]);
}

}
else
{
for(int i=m;i<n;i++)
{
if(carry!=0)
{
c.push_back(a[i]+carry);
carry=0;
}
else
c.push_back(a[i]);
}
}
reverse(c.begin(),c.end());
for(int i=0;i<c.size();i++)
cout<<c[i]<<", ";
cout<<“END”;

return 0;

}

@rockstarpkm,
Please provide a cb.lk/ide link of your complied code.


here’s the link to my code

@rockstarpkm,
Try you code against this,

Input:
5
9 9 9 9 9
4
9 9 9 9

1 Like