By: Prem Tiwari | Last Updated:
In this tutorial, we will explain a simple program which will convert the number from binary to the decimal number system. We have not used any validation in number input as this program is designed for the beginners for learning purpose.
You can modify this program to validate the number entered by the user during the program execution time, then the user can only enter the binary number in the combination of (0, 1).
Below is the algorithm of number conversion from binary to decimal.
Copy the below c program and execute it with c compiler to see the output of the program and also start converting the number system from binary number to decimal number.
void bin_dec(long int num) // Function Definition
long int temp,sum=0,power=0;
temp = num%10;
num = num/10;
sum = sum + temp * pow(2,power);
printf("Decimal number : %d",sum);
long int num;
printf("Enter the Binary number (0 and 1): ");
Enter the Binary number (0 and 1) : 101
Decimal number : 5
Enter the Binary number (0 and 1): 111011
Decimal number : 59
Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.View all posts by Prem Tiwari
Tags: binary number to decimal, binary to decimal number, conversion of binary numbers to decimal, convert binary number to decimal number, convert binary to decimal number, decimal number to binary, how to convert binary numbers to decimal, program to convert binary to decimal in c