fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int n;
  6. int a[32];
  7. int i = 0;
  8.  
  9. scanf("%d", &n);
  10.  
  11. if (n == 0) {
  12. printf("0");
  13. return 0;
  14. }
  15.  
  16. while (n > 0) {
  17. a[i] = n % 2;
  18. n = n / 2;
  19. i=i+1;
  20. }
  21. for (int j = i - 1; j >= 0; j--) {
  22. printf("%d", a[j]);
  23. }
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5316KB
stdin
177
stdout
10110001