I have being try to understand why there is the output not all the elements are print only first and second are print individually but not the third it starts the combination not the single third as still in the second loop when j=3 for which (counter &(1<<j)) is also true.so here is the code:
for (int counter = 1; counter < opsize; counter++)
{
for (int j = 0; j < n; j++)
{
/* Check if jth bit in the counter is set
If set then print jth element from arr[] */
if (counter & (1<<j))
cout << arr[j] << " ";
}
cout << endl;
}
}