Can anyone tell me what is going on in this code, step by step, because when I calculate this in a paper, it should be a wrong result, but the coe is working fine, I need a step by step explanation.
#include<stdio.h>
#include<conio.h>
int main()
{
int d, i, pos=1, b=0;
printf("Enter the binary number");
scanf("%d",&d);
do
{
b=b+(pos * (d%10)) ;
pos = pos*2;
d = d/10;
}
while (d>0);
printf("%d", b);
getch();
}