C Programming Code Examples C > Conversions Code Examples Program to Convert Binary Number to Decimal Number Program to Convert Binary Number to Decimal Number Accept Number from User Divide Number by 10 and Store Remainder in variable rem Divide Original Number by 10. Inside the First Iteration power = 0. Power is Incremented in each Iteration. Calculate sum using the above formula, calculated sum is nothing but the decimal representation of the given binary number. #include<stdio.h> #include<conio.h> #include<math.h> void bin_dec(long int j) // Function Definition { long int rem,sum=0,power=0; while(j>0) { rem = j%10; j = j/10; sum = sum + rem * pow(2,power); power++; } printf("Decimal number : %d",sum); } //------------------------------------- void main() { long int j; clrscr(); printf("Enter the Binary number (0 and 1): "); scanf("%ld",&j); bin_dec(j); getch(); }