C Programming Code Examples C > Conversions Code Examples C Program to Convert Binary Number to Decimal Number C Program to Convert Binary Number to Decimal Number In this program, we have created a user defined function binaryToDecimal() for binary to decimal conversion. This programs takes the binary number (entered by user) as input and converts it into a decimal number using function. To understand this program, you should be familiar with the following C programming concepts: #include <stdio.h> #include <math.h> int binaryToDecimal(long binarynumber) { int decimalnumber = 0, temp = 0, remainder; while (binarynumber!=0) { remainder = binarynumber % 10; binarynumber = binarynumber / 10; decimalnumber = decimalnumber + remainder*pow(2,temp); temp++; } return decimalnumber; } int main() { long binarynumber; printf("Enter a binary number: "); scanf("%ld", &binarynumber); printf("Equivalent decimal number is: %d", binaryToDecimal(binarynumber)); return 0; }