Hey there,I'm looking for assistance with my simple code here.
Why do my integers ( x,v,z,d,e,f,g,h ) suddenly change when the program reaches the " printf("The decimal value is... " part? Is there something I'm missing?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int Binary[7],x,v,z,d,e,f,g,h;
Binary[0]=x;
Binary[1]=v;
Binary[2]=z;
Binary[3]=d;
Binary[4]=e;
Binary[5]=f;
Binary[6]=g;
Binary[7]=h;
int decimal,numm0,numm1,numm2,numm3,numm4,numm5,numm6,numm7;
decimal = x*128+v*64+z*32+d*16+e*8+f*4+g*2+h*1;
numm0=x*128;
numm1=v*64;
numm2=z*32;
numm3=d*16;
numm4=e*8;
numm5=f*4;
numm6=g*2;
numm7=h*1;
printf("Binary to Decimal conversion");
printf("\n==========================\n");
printf("Please enter a 8-digit Decimal:");
scanf("%d,%d,%d,%d,%d,%d,%d,%d",&x,&v,&z,&d,&e,&f,&g,&h);
printf("Your entered value is %d\n",x,v,z,d,e,f,g,h);
printf("The decimal value is\n(%dx128=%d)+(%dx64=%d)+(%dx32=%d)+(%dx16=%d)+(%dx8=%d)+(%dx4=%d)+(%dx2=%d)+(%dx1=%d)=%d\n",x,numm0,v,numm1,z,numm2,d,numm3,e,numm4,f,numm5,g,numm6,h,numm7,decimal);
system("pause");
return 0;
}