title: adding leading zeros to decimal to binary array C
body: <p>I am converting decimal to binary and I need my output to be 32 (bits?) long. This works as I intend, but I am not getting the leading zeros, for instance, the input "3" gives me "11", instead of "00000000000000000000000000000011"</p>
  
  <pre><code>    int i = 0;
      int bi[31];
  
      while(num &gt; 0){
          if(num % 2 == 0)
              bi[i] = 0;
          else
              bi[i] = 1;
          i++;
          num = num / 2;
      }
      for(int j = i - 1; j &gt;= 0; j--){
          printf("%d", bi[j]);
      }
  </code></pre>
  
  <p>I originally thought this would be as simple as changing my printout to just loop down from 31 to 0 and print out all the contents of the array, assuming zeros would be in everything not in my bi[] array. But that does not work :)</p>
  
  <p>Thanks</p>