Segmentation error in this code. i am not able to figure out why

#include
using namespace std;
void helper(int* a,int j,int* input,int i,int* b,int k,int n,int &sum1,int &sum2){

//base case
if(i==n){
if(sum1==sum2){
for(int p=0;p<j;p++){
cout<<a[p]<<" ";
}cout<<"and “;
for(int s=0;s<k;s++){
cout<<b[s]<<” ";
}
cout<<endl;
}
return ;
}

//recursive case
a[j]=input[i];
sum1=a[j]+input[i];
helper(a,j+1,input,i,b,k,n,sum1,sum2);
b[k]=input[i];
sum2=b[k]+input[i];
helper(a,j,input,i+1,b,k+1,n,sum1,sum2);

}
int main() {
int n;
cin>>n;
int input[n];
for(int i=0;i<n;i++){
cin>>input[i];
}
int a[n];
int b[n];
int sum1=0;
int sum2=0;
helper(a,0,input,0,b,0,n,sum1,sum2);

}

hi @uvanshika,
please save the code on ide.codingblocks.com here it is not readable

Its done,can you check now

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.