/*
program to convert binary no. to decimal no.....
*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
unsigned long int a,b,c=0,s=0,n;
clrscr();
cout<<"Enter your binary number:";
cin>>a;
while (a>0)
{b=a%10;
n=b*pow(2,c);
c+=1;
a=a/10;
s+=n;
}
cout<<"The corresponding decimal no. is="<<s;
getch();
}
program to convert binary no. to decimal no.....
*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
unsigned long int a,b,c=0,s=0,n;
clrscr();
cout<<"Enter your binary number:";
cin>>a;
while (a>0)
{b=a%10;
n=b*pow(2,c);
c+=1;
a=a/10;
s+=n;
}
cout<<"The corresponding decimal no. is="<<s;
getch();
}
0 comments:
Post a Comment