#include <stdio.h>
#include <Conio.h>
int main()
{
int bin, dec= 0, base = 1, rem;
printf("Enter the Binary Number = ");
scanf("%d", &bin);
int temp = bin;
while(temp > 0)
{
rem = temp % 10;
dec = dec + rem * base;
temp = temp / 10;
base = base * 2;
}
printf("The Decimal Value of %d is %d\n", bin, dec);
getch();
return 0;
}
Enter the Binary Number = 10111
The Decimal Value of 10111 is 23
--------------------------------
Process exited after 6.41 seconds with return value 0
Press any key to continue . . .