C Program to convert binary number to decimal number
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
unsigned long i,n,num=0,d;
cout<<"Enter any Binary number:";
cin>>n;
cout<<"
The Decimal conversion of "<<n<<" is ";
for(i=0;n!=0;++i)
{
d=n%10;
num=(d)*(pow(2,i))+num;
n=n/10;
}
cout<<num;
getch();
}
No comments:
Post a Comment