Array-sum of two array

#include<bits/stdc++.h>
using namespace std;
int calsum(int arr1[],int arr2[],int n,int m)
{
int sum[n];
int i=n-1,j=m-1,k=n-1;
//i iterator for first array with more size
//j iterator for second array with less size
//k for new array
int carry=0,sum=0;
//iterate over smaller array
while(j>=0)
{
s=arr1[i]+arr2[j]+carry;
sum[k]=(s%10);
carry=s/10;
k–;
i–;
j–;
}
int ans=0;
if(carry)
{

	}

}
int main()
{
int n,m;
cin>>n;
int *arr1=new int[n];
for(int i=0;i<n;i++)
cin>>arr1[i];
cin>>m;
for(int i=0;i<m;i++)
cin>>arr2[i];
}
how to deal with corner case i.e sum is still there,pls help me to write this case,my program is incomplete

Hey Shubham, can you please copy your code on ide, save it and share that link here, as the code you copied here is giving so many compilation errors.

my code is not complete mam will give error,pls tell me what logic to write if their is a carry
https://ide.geeksforgeeks.org/nDAUOLqVtQ

Hey Shubham,

  1. you are not handling the case when size of both the arrays is not the same,
  2. you can’t use same variable name for for an array and an integer in same function, so use a different variable name instead of sum for any one of them.
  3. you can’t use an array without declaring it, in your code you haven’t declared arr2 anywhere.
  4. you haven’t called the function calcsum then how will it be executed for your input.