How to Convert Binary to Decimal by C Programming?

Through this tutorial, you can easily convert the value of binary to decimal through c language. You are also explained as an example below.

Convert Binary to Decimal Using C Program, Binary to Decimal canvert by C Program, C Program Convert Binary to Decimal Value

Through c language you can very easily convert binary to decimal. Program in c language is written below. You can easily test in your computer by writing the c program written in your file below.

Binary to Decimal Convert Using C Language

#include<stdio.h>
#include<math.h>
int main()
{
long int i,n,x=0,y;
printf("Enter here any binary number: ");
scanf("%ld",&n);
printf("\nThe decimal conversion of %ld is ",n);
for(i=0;n!=0;++i)
{
y=n%10;
x=(y)*(pow(2,i))+x;
n=n/10;
}
printf("%ld",x);
return 0;
}

Output

Enter any binary number: 11101
The decimal conversion of 11101 is 29