title: Test result fails for my code of Inspect Bits function
body: <p>Below code is for a test sample given in <a href="https://www.testdome.com/for-developers/solve-question/9780" rel="nofollow noreferrer">https://www.testdome.com/for-developers/solve-question/9780</a></p>
  
  <p>The question is: Implement the inspect_bits function that checks if given number contains 2 or more consecutive ones in its binary representation. If it does, the function should return 1. Otherwise, it should return 0.</p>
  
  <p>For example, inspect_bits(13) should return 1 as it contains 2 consecutive ones in its binary representation (1101).</p>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  int inspect_bits(unsigned int number)
  {
      unsigned int ref = 1;
      int comp;
  
      for (int i = 0; i&lt; sizeof(number) * 8; i++)
      {
          int a = number&amp; (ref &lt;&lt; i);
          printf("%d: a is %d\n", i, a);
          int b = number&amp; (ref &lt;&lt; (i + 1));
          printf("%d: b is %d\n", i, b);
          if ((a != 0) &amp;&amp; (b != 0))
          {
              return 1;
          }
      }
      return 0;
  }
  
  #ifndef RunTests
  int main()
  {
      printf("%d", inspect_bits(13));
  }
  #endif  
  </code></pre>
  
  <p>The result seems ok, but the system tells: 
    Various numbers: Wrong answer </p>
  
  <p>Can you help to modify my code?</p>
  
  <p>Regards</p>