SabirSazzad

Decimal to Binary (another process)

Feb 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     long dec,rem,i=1,sum=0;
  6.     int num[1000];
  7.     cout<<"Enter the decimal to be converted:";
  8.     cin>>dec;
  9.     do
  10.     {
  11.         rem=dec%2;
  12.         sum=sum + (i*rem);
  13.         dec=dec/2;
  14.         i=i*10;
  15.     }while(dec>0);
  16.     cout<<"The binary of the given number is:"<<sum<<endl;
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment