Not getting correct answer

#include
using namespace std;
int ans=0;
void subseq(char *input ,char *output,int i,int j){
if(input[i]==’\0’){
output[j]=’\0’;
cout<<output<<" ";
ans++;
return;
}
output[j]=input[i];
subseq(input,output,i+1,j);
subseq(input,output,i+1,j+1);

}

int main() {
char input[10];
cin>>input;

char output[10];
//cout<<endl;
subseq(input,output,0,0);
cout<<endl;
cout<<ans;
return 0;
}

@priyeshant1104 please share your code using cb ide so that i can check

@priyeshant1104 corrected and commented


dont forget to hit like and mark resolved if cleared :smiley:

can you explain why we change the order?

@priyeshant1104 you were excluding first and also including it in the output array so it doesnt make any sense you can only do two things
out[j]=inp[i]
i+1,j+1
i+1,j
or
i+1,j
in[i]=out[j]
i+1,j+1
first one prints in normal manner
second one in reverse as mentioned in question
you were doing something else

Thanks for the clarification

np @priyeshant1104 just mark it resolved