I think this is the solution of your problem and this code does not uses even
if keyword. But i have use a function.
//Program to convert a binary number to its equivalent decimal number
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int count_digits(int);
int num,n,R,r,dec=0;
clrscr();
printf("\nEnter a number in binary form : ");
scanf("%d",&num);
n=count_digits(num);
while(num)
{
r=num%10;
R=r*pow(2,--n);
dec+=R;
num=num/10;
}
printf("\nDecimal : %d", dec);
getch();
return 0;
}
int count_digits(int num) //Function to count to digits
{
int n=0;
while(num)
{
num/=10;
n++;
}
return n;
}