Guest User

Untitled

a guest
Jul 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <iostream.h>
  7.  
  8. main()
  9. {
  10. int x,i,n,a[100];
  11.  
  12. cout<<"Nhap vao so nguyen : ";
  13. cin>>x;
  14. cout<<"\n So "<<x<<" chuyen sang co so 2 la : ";
  15. n=0;
  16. while (x>0)
  17. {
  18. a[n]=x%2;
  19. x=x/2;
  20. n=n+1;
  21. }
  22. for (int i=n;i>=0;i--)
  23. cout<<a[i];
  24. getch();
  25. }
Add Comment
Please, Sign In to add comment