fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int a[10], n, i;
  6. cout<<"Enter the number to convert: ";
  7. cin>>n;
  8. for(i=0; n>0; i++)
  9. {
  10. a[i]=n%2;
  11. n= n/2;
  12. }
  13. cout<<"Binary of the given number= ";
  14. for(i=i-1 ;i>=0 ;i--)
  15. {
  16. cout<<a[i];
  17. }
  18. }
Success #stdin #stdout 0s 15232KB
stdin
9000
stdout
Enter the number to convert: Binary of the given number= 10001100101000