- Enter a binary number and assign it to the b variable:
printf("Enter a number in binary number ");scanf("%d",&b);
- Invoke the intodecimal function to convert the binary number into a decimal number, and pass the b variable to it as an argument. Assign the decimal number returned by the intodecimal function to the d variable:
d=intodecimal(b);
- On looking at the intodecimal definition, int intodecimal(int bin) { }, we can see that the b argument is assigned to the bin parameter of the intodecimal function.
- Separate all the binary digits and multiply them by 2 raised to the power of their position in the binary number. Sum the results to get the decimal equivalent. To separate each binary digit, we need to execute a while