CPP Program to convert binary number into Decimal Number

This simple binary to decimal converter takes one binary number from the keyboard and convert the same number using place value method into its equivalent decimal number. The program was tested on window 10 using Dev C++ IDE.

/*	program to convert any binary number into its equivalent decimal number
	made by		: rakesh kumar
using namespace std;
int main(){
	int n,i=0,sum=0;
	int rem;
	//input phase
	cout<<"\n Enter any binary number : "; cin>>n;
	//processing phase
		rem = n%10;
		sum = sum + rem* pow(2,i);
		n = int(n/10);
	cout<<"\n Decimal No :"<<sum;

The output of the above program is as follows

binary to decimal number converter program

%d bloggers like this: