5/07/2016

Decimal to binary conversion with c++ programming

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


--------------------------

SEARCH ALL TOPICS AND PROGRAMMINGS


Please just write a comment.






1 comment:

  1. Please give the programming of the conversion of binary to decimal.

    ReplyDelete