Out of 4 testcases,2 testcases are not passing…please help where i am doing the mistake.??
my code
#include
#define ll long long int
using namespace std;
void sumofarray(int a[],int b[],int n,int m)
{
int i=n-1,j=m-1,carry=0,sum;
ll k=max(n,m);
ll c[k];
ll l=k-1;
while(i>=0 && j>=0)
{
sum=a[i–]+b[j–]+carry;
if(sum>=10)
{
c[l–]=sum%10;
carry=sum/10;
}
else
{
c[l–]=sum;
carry=0;
}
}
while(i>=0)
{
c[l--]=a[i--]+carry;
}
while(j>=0)
{
c[l--]=b[j--]+carry;
}
for(l=0;l<k;l++)
{
cout<<c[l]<<", ";
}
cout<<"END"<<endl;
}
int main()
{
int n,i,j;
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
int m;
cin>>m;
int b[m];
for(j=0;j<m;j++)
cin>>b[j];
sumofarray(a,b,n,m);
return 0;
}