fork download
  1. #include <iostream>
  2.  
  3. void printInBinary(unsigned int num)
  4. {
  5. unsigned int tmp = num;
  6. unsigned char size = 0;
  7. while (tmp)
  8. {
  9. tmp /= 2;
  10. ++size;
  11. }
  12.  
  13. for (char i = size - 1; i >= 0; --i)
  14. {
  15. std::cout << (num >> i)%2;
  16. }
  17. }
  18.  
  19. int main() {
  20. printInBinary(5000);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
1001110001000