title: What does the statement if (counter & (1<<j)) mean and how does it work?
body: <p>I was working on an algorithm of sub sequences.</p>
  <p>What is the meaning of the statement:</p>
  <pre><code>if (counter &amp; (1&lt;&lt;j))
  </code></pre>
  <p>within the context of the program below:</p>
  <pre><code>void printSubsequences(int arr[], int n)
  {
      unsigned int opsize = pow(2, n);
  
      for (int counter = 1; counter &lt; opsize; counter++)
      {
          for (int j = 0; j &lt; n; j++)
          {
              if (counter &amp; (1&lt;&lt;j))
                  cout &lt;&lt; arr[j] &lt;&lt; &quot; &quot;;
          }
          cout &lt;&lt; endl;
      }
  }
  </code></pre>