fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <iostream>
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11. int main(){
  12. int num;
  13. cout << "Digite um número";
  14. cin >> num;
  15. int binario[8];
  16. for (int i = 0; num > 0; i++) {
  17. binario[i] = num % 2;
  18. num = num / 2;
  19.  
  20. }
  21. cout << binario;
  22. return 0;
  23. }
  24.  
  25.  
Success #stdin #stdout 0.01s 5320KB
stdin
45
stdout
Digite um número0x7ffebbafe900