C++ PROGRAM TO CONVERT DECIMAL NUMBER TO BINARY NUMBER
Sample Test Case : Enter the Number : 3
Sample Output : Binary equivalent of 3 is 11
CODE
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num,bin;
cout<<"Enter the Number :";
cin>>num;
cout<<"Binary equivalent of"<<num<<"is :";
while(num>0)
{
bin=num%2;
cout<<bin;
num/=2;
}
return 0;
}

No comments:
Post a Comment