#include <stdio.h>
int main()
{
int num, binary_val, decimal_val = 0, base = 1, rem;
printf("Insert a binary num (1s and 0s)
");
scanf("%d", &num);
binary_val = num;
while (num > 0)
{
rem = num % 10;
decimal_val = decimal_val + rem * base;
num = num / 10 ; //these are the correct lines
base = base * 2; //these are the correct lines
}
printf("%d
", binary_val);
printf("%d
", decimal_val);
return 0;
}