https://hack.codingblocks.com/contests/c/474/217
i am not able to handle the condition when size of two arrays are diiferent
here is the code since i am not able to save the code on coding blocks ide so i am pasting it here
#include
using namespace std;
int main() {
int n;
cin>>n;
int arr1[n];
for(int i=0;i<n;i++){
cin>>arr1[i];
}
int m;
cin>>m;
int arr2[m];
for(int i=0;i<m;i++){
cin>>arr2[i];
}
int len=max(n,m) ;
int arr3[len];
int carry=0;
int i=n-1, j=m-1, k=len-1;
while(i>=0 && j>=0){
int sum=arr1[i]+arr2[j]+carry;
arr3[k]=sum%10;
carry=sum/10;
k--;
i--;
j--;
}
while(i>=0){
int sum=arr1[i]+carry;
arr3[k]=sum%10;
carry=sum/10;
k--;
i--;
}
while(j>=0){
int sum=arr2[i]+carry;
arr3[k]=sum%10;
carry=sum/10;
k--;
j--;
}
for(int i=0;i<len;i++){
cout<<arr3[i]<<", ";
}
cout<<"END";
}