C++ Program that Convert Dec Number to Binary using Bitwise Oprt
#include <iostream>
using namespace std;
int main()
{
long dec,c,m,bit;
cout<< "Enter the bit : ";
cin>>bit;
cout<< "Enter the Decimal : ";
cin>>dec;
for(c=bit;c>=0;c--){
m=dec>>c;
if(m&1)
cout<< "1";
else
cout<< "0";
}
return 0;
}
No comments:
Post a Comment