Generate subsets in bitmanipulation

please let me understand the for loop in print subsets .
i am unable to understand i<(1<<n)

hello @khushiujjawal

If we list down all the binary numbers from 0 to (2^n)-1 , we get ALL the possible combinations of selecting n items"

** for example if n=3**

0->000: None of the values in the set chosen

1->001: 1st chosen, 2nd and 3rd items left out

2->010: 2nd chosen, 1st and 3rd items left out

3->011: 1st and 2rd item chosen, 3rd one left out.

7->111: All 3 items chosen

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.