Here you will get the program to change over binary to decimal in C.
We can acquire a decimal number by increasing every digit of binary number with intensity of 2 and including
every augmentation result. The power begins from 0 and goes to n-1 where n is the all outnumber of digits in a binary number.
The following is the program to execute this in C.
Program
#include<stdio.h>
#include<math.h>
int main()
{
long int i,n,x=0,a;
printf("Enter any binary number: ");
scanf("%ld",&n);
printf("\nThe decimal conversion of %ld is ",n);
for(i=0;n!=0;++i)
{
a=n%10;
x=(a)*(pow(2,i))+x;
n=n/10;
}
printf("%ld",x);
return 0;
}
Output
Enter any binary number: 111
The decimal conversion of 111 is 7