Decimal to binary conversion
(only for integer number)
-----------------------------------------------
#include<iostream>
using namespace std;
int main()
{
int no,i=1,a,b[1000],cons;
cout<<"Enter an integer number no.:";
cin>>no;
do
{
a=no/2;
b[i]=no%2;
no=a;
i++;
}
while(no>0);
cons=i-1;
cout<<"Equivalent binary no.:\n";
for(i=cons:i>=1;i--)
{
cout<<b[i];
}
return 0;
}
Output:
Enter an integer no.:30
Equivalent binary no.:
11110
Please just write a comment.
Please give the programming of the conversion of binary to decimal.
ReplyDelete