Code correct but test case not passing

#include
using namespace std;
int count=0;
int subsequence(char *in,char *out, int i, int j){
if(in[i]==’\0’){
out[j]=’\0’;
cout<<out<<" ";
count++;
return count;
}
out[j]=in[i];
subsequence(in,out,i+1,j+1);
subsequence(in,out,i+1,j);
}
int main() {
char a[100],out[100];
cin>>a;
cout<<endl<<subsequence(a,out,0,0);
return 0;
}

Hi @goeljatin95
Your logic is correct. Only thing is that what you are printing is not the desired output. You have to print those output in reverse order. For example when input is abc you code is printing output as :

abc ab ac a bc b c 8
but the correct output is :
c b bc a ac ab abc
8

To correct this you have a take a stack and instead of print out you just push it in stack. And in main function compute x=subsequence(a,out,0,0) and then print elements in the stack and then print x.

Here is your corrected code :

Mark your doubt as resolved if it is clear.