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.

- Accept Number from User as 0,1
- Divide number by 10 and store remainder in variable temp
- Again divide the original number by 10.
- Then calculate the sum of number to get the 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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include<stdio.h> #include<conio.h> #include<math.h> void bin_dec(long int num) // Function Definition { long int temp,sum=0,power=0; while(num>0) { temp = num%10; num = num/10; sum = sum + temp * pow(2,power); power++; } printf("Decimal number : %d",sum); } //------------------------------------- void main() { long int num; clrscr(); printf("Enter the Binary number (0 and 1): "); scanf("%ld",&num); bin_dec(num); getch(); } |

#First try

Enter the Binary number (0 and 1) : 101

Decimal number : 5

#Second try

Enter the Binary number (0 and 1): 111011

Decimal number : 59

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- C program to remove consecutive repeated characters from string
- C Program to Read and Print details of 50 Students using Structure
- C program to Use structure within union & display the contents of structure elements
- C program to find area of scalene triangle
- C program to implement bit flipping
- C program to implement hashing
- C program to implement SJF algorithm
- stdio.h library functions list in c
- conio.h functions list in c
- C program remove spaces, blanks from a string

Article 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

We use cookies to ensure that we give you the best experience on our website. We and our partners are using technologies like cookies in order to personalize the advertising that you see. This helps us to show you more relevant ads and improves your internet experience. Read more about our Privacy Policy.Got it!