/*******************************************************
* Program to convert a binary number to decimal number
********************************************************/
#include<stdio.h> // include stdio.h
#include<math.h> // include stdio.h
int main()
{
long int bin, remainder, decimal = 0, i = 0;
printf("Enter a binary number: ");
scanf("%d", &bin);
while(bin != 0)
{
remainder = bin % 10;
decimal += remainder * (int)pow(2, i++);
bin = bin / 10;
}
printf("Decimal: %d", decimal);
return 0;
}