#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
                int bin,num=0,i=0,rem=0;
                clrscr();
                cout<<"Enter The Binary Number :- ";
                cin>>bin;
                while(bin>0)
                                {
                                rem=bin%10;
                                num=num+rem*pow(2,i);
                                bin=bin/10;
                                i++;
                                }
                cout<<"The Decimal Number :- "<<num;
                getch();
}

35

Advertisements