fork(1) download
  1. #include <stdio.h>
  2.  
  3. void printbinary(unsigned x, unsigned count){
  4.  
  5. printf("decimal is: %d\n",x);
  6. printf("binary is: ");
  7.  
  8. putchar('b');
  9.  
  10. while (0 < count){
  11. putchar(((x >> (count - 1u)) & 1u) + '0');
  12. count--;
  13. }
  14.  
  15. putchar('\n');
  16. }
  17.  
  18. int main(void) {
  19. printbinary(1, 8);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
decimal is: 1
binary is: b00000001