#include<iostream>
#include<stack>
using namespace std;
int main()
{
stack<int> s;
int num, r;
cout<<"Enter a number"<<endl;
cin>>num;
cout<<"The binary code of "<<num<<" is ";
while(num !=0 )
{
r = num % 2;
num = num / 2;
s.push(r);
}
while(!s.empty())
{
cout<<s.top();
s.pop();
}
cout<<endl;
system("pause");
return 0;
}
|
![]() |