Subsequences(()))

why two times ac is getting printed after running the code??
#include
using namespace std;

void subsequence(char *in, char *out, int i, int j)
{
// base case
if (in[i] == ‘\0’)
{
out[j] == ‘\0’;
cout << out << endl;
return;
}

// recursive case
// 1. ignore the ith character
subsequence(in, out, i + 1, j);

// 2. Take the ith character and update the value of j as well as i
out[j] = in[i];
subsequence(in, out, i + 1, j + 1);

}

int main()
{
char in[100];
cin.getline(in, 100);
char out[100];
// cin.getline(out,100);

subsequence(in, out, 0, 0);

return 0;

}

hi @abhinavssr2003_eab0717682969e5c,
out[j] = '\0' not ==

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.