Segmentation error at line 4

I am getting segmentation fault in this code and i am not able to figure out the reason.

#include
using namespace std;
void subset(int input[],int output[],int i,int j,int n){

//base case
if(i == n){
int sum=0;
for(int k=0;k<j;k++){
sum=sum+output[k];
}
if(sum==0){
cout<<“Yes”;
}else {
cout<<“No”;
}
return ;
}

//recursive case
subset(input,output,i+1,j,n);
output[j]=input[i];
subset(input,output,i+1,j+1,n);

}
int main() {
int n;
int input[100];
for(int i=0;i<n;i++){
cin>>input[i];
}
int output[100];
subset(input,output,0,0,n);
}

hi @uvanshika, CODE NOT READABLE so…
go to ide.codingblocks.com
copy paste your code
save (ctrl + s)
then send the url of that page

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.

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.

I am getting segmentation fault in this code and i am not able to figure out the reason.

#include
using namespace std;
void subset(int input[],int output[],int i,int j,int n){

//base case
if(i == n){
int sum=0;
for(int k=0;k<j;k++){
sum=sum+output[k];
}
if(sum==0){
cout<<“Yes”;
}else {
cout<<“No”;
}
return ;
}

//recursive case
subset(input,output,i+1,j,n);
output[j]=input[i];
subset(input,output,i+1,j+1,n);

}
int main() {
int n;
int input[100];
for(int i=0;i<n;i++){
cin>>input[i];
}
int output[100];
subset(input,output,0,0,n);
}

@uvanshika
CODE NOT READABLE so…
go to ide.codingblocks.com
copy paste your code
save (ctrl + s)
then send the url of that page