title: convert integer to 32-bit binary in c
body: <p>I'm writing a program to convert an integer to 32-bit binary. The problem is with the output - it comes backwards. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      long number, binary, num2;
  
      printf("Enter an integer: ");
      scanf("%ld", &amp;number);
  
      for (num2 = (number * 2) / 2; num2 &gt; 0; num2 /= 2) {
          binary = num2 % 2;
          printf("%ld", binary);
      }
      putchar('\n');
      return 0;
  }
  </code></pre>
  
  <p>So if I put '6' it shows as 011 and it has to be 110</p>
  
  <p>Also, how do I output the rest of '0's? So that the whole output in this case would be: </p>
  
  <pre><code>00000000 00000000 00000000 00000110 
  </code></pre>