Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,n1,n2,n3,n4,n5,n6,n7,n8,b1,b2,b3,b4,b5,b6,b7,b8;
- cout<<"Enter your number: ";
- cin>>n;
- n1=n/2;
- b1=n%2;
- n2=n1/2;
- b2=n1%2;
- n3=n2/2;
- b3=n2%2;
- n4=n3/2;
- b4=n3%2;
- n5=n4/2;
- b5=n4%2;
- n6=n5/2;
- b6=n5%2;
- n7=n6/2;
- b7=n6%2;
- b8=n7%2;
- cout<<"The binary is: "<<b8<<b7<<b6<<b5<<b4<<b3<<b2<<b1<<endl;
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment