fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int inteiro = 3;
  5. int tamanho = sizeof(int) * 8;
  6. char binario[tamanho + 1];
  7. int i = tamanho - 1;
  8. while (i > 0) {
  9. binario[i] = inteiro % 2 + 48;
  10. inteiro /= 2;
  11. i--;
  12. }
  13. binario[tamanho] = '\0';
  14. printf("%s", binario);
  15. }
  16.  
  17. //https://pt.stackoverflow.com/q/83420/101
Success #stdin #stdout 0s 4320KB
stdin
Standard input is empty
stdout
Standard output is empty