I have done this code ,but I think there could be a better approach here for this question.
#include
#include
#include
using namespace std;
void function(int n ,int arr[] ,int m,int arr1[])
{
string s1,s2,s3;
for (int i=0;i<n;i++) {
s1+=to_string(arr[i]);
}
for (int i=0;i<m;i++) {
s2+=to_string(arr1[i]);
}
int x,y;
x=stoi(s1);
y=stoi(s2);
int val=x+y;
s3=to_string(val);
for(int i=0;i<s3.size();i++)
{
cout<<s3[i]<<", ";
}
cout<<"END";
}
int main() {
int n,m;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>m;
int arr1[m];
for(int i=0;i<m;i++)
{
cin>>arr1[i];
}
function(n,arr,m,arr1);
return 0;
}