title: How to implement Bitcount using only Bitwise operators?
body: <p>The task is to implement a bit count logic using only bitwise operators. I got it working fine, but am wondering if someone can suggest a more elegant approach. </p>
  
  <p>Only Bitwise ops are allowed. No "if", "for" etc</p>
  
  <pre><code>int x = 4;
  
  printf("%d\n", x &amp; 0x1);
  printf("%d\n", (x &gt;&gt; 1) &amp; 0x1);
  printf("%d\n", (x &gt;&gt; 2) &amp; 0x1);
  printf("%d\n", (x &gt;&gt; 3) &amp; 0x1);
  </code></pre>
  
  <p>Thank you.</p>