Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- void main()
- {clrscr();
- int d,n,b[10],i=0,r,j;
- cout<<"Enter a decimal number";
- cin>>d;
- n=d;
- while (n)
- {r=n%2;
- b[i]=r;
- i++;
- n=n/2;
- }
- cout<<"The binary equivalent of the number is:";
- for(j=i-1;j>=0;j--)
- cout<<b[j];
- getch();
- }
Add Comment
Please, Sign In to add comment