Featured
- Get link
- X
- Other Apps
C++ program to convert binary to decimal
C++ program to convert binary to decimal
//program to convert a binary no. into decimal no.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
long int n,x;
cout<<"Please enter a binary no. "<<endl;
cin>>n;
x=n;
int rem=0,sum=0;
for(int ctr=0;n>0;ctr++)
{ rem=n%10;
rem=rem*(pow(2,ctr));
sum=sum+rem;
n=n/10;
}
cout<<"Decimal Equivalent of "<<x<<" is "<<sum<<endl;
getch();
}//end main
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment