Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <iostream.h>
- main()
- {
- int x,i,n,a[100];
- cout<<"Nhap vao so nguyen : ";
- cin>>x;
- cout<<"\n So "<<x<<" chuyen sang co so 2 la : ";
- n=0;
- while (x>0)
- {
- a[n]=x%2;
- x=x/2;
- n=n+1;
- }
- for (int i=n;i>=0;i--)
- cout<<a[i];
- getch();
- }
Add Comment
Please, Sign In to add comment