Convert Decimal Number to Binary Number System

Convert Decimal Number to Binary Number System Using C++



========================================================================


#include<iostream>
using namespace std;
main()
{
  int n,c,k;
   cout<<"Enter an integer in decimal number system\n";
   cin>>n;
   cout<<n<<"in binary number system is:\n"<<n<<endl;
  for (c=10;c>=0;c--)
  {
    k=n>>c;
    if (k&1)
      cout<<"1";
    else
     cout<<"0";
  }
  cout<<endl;
}


========================================================================

OutPut :



SHARE
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment