Array sum of two arrays

#include
using namespace std;

int main()
{
int n;
cin>>n;
int a[1000];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int m;
cin>>m;
int b[1000];
for(int i=0;i<m;i++)
{
cin>>b[i];
}

int starr1=0,endarr1=n-1,starr2=0,endarr2=m-1;
int arr[1000];
int temp[1000];
int k=max(n,m)-1;
int carry=0,carry1;
while(endarr1>=starr1 and endarr2>=starr2)
{
	arr[k]=a[endarr1]+b[endarr2]+carry;
	carry= arr[k] / 10;
    arr[k] = arr[k] % 10;
	k--;
	endarr1--;
	endarr2--;
	if(a[endarr1]==0)
	{
	arr[k]=b[endarr2];
	}	
	if(a[endarr2]==0)
	{
		arr[k]=a[endarr1];
	}
carry1=carry;
}

if(carry1==0)
{
for(int k=0;k<max(n,m);k++)
{
	cout<<arr[k]<<", ";	
}
}
else
{
	cout<<carry1<<", ";
	for (int k=0;k<max(n,m);k++)
	{
		cout<<arr[k]<<", ";
	}
}
cout<<"END";
return 0;

}
i am getting one test case failed it says wrong answer
please solve my problem

hello @AKSHET
for given input

correct answer is 1998 but urs is giving 998

Try again because I am getting 1, 9, 9, 8, END

I m running this code link -> https://ide.codingblocks.com/s/231341

it is showing 998,
if ur code is different than this then pls share the updated one.

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.