# Hexa convert to binary. sum all binary numbers.

basically, i need to add 8 hexadecimal numbers. and each hexadecimal numbers need to be change to binary numbers. After that, i need to do summation for all binary numbers that i've changed.

for example = A+B+C+D+1+2+3+4
changed to binary = 1010+1011 +1100+1101+0001+0010+0011+0100
summation = 101110

i need to do this using C language...

[code]
#include
#include

int main()
{
int i,sum=0;
char s[20];
");
printf("Enter a Hexadecimal number of array:
");

for (i=0;i<8;i++)
scanf("%s",&s[i]);
printf("Binary Equivalent= ");
for (i=0;i<8;i++)
for(i=0;s[i]!=NULL;i++)

switch(s[i])
{
case '0':
printf("0000");
break;
case '1':
printf("0001");
break;
case '2':
printf("0010");
break;
case '3':
printf("0011");
break;
case '4':
printf("0100");
break;
case '5':
printf("0101");
break;
case '6':
printf("0110");
break;
case '7':
printf("0111");
break;
case '8':
printf("1000");
break;
case '9':
printf("1001");
break;
case 'a':
case 'A':
printf("1010");
break;
case 'b':
case 'B':
printf("1011");
break;
case 'c':
case 'C':
printf("1100");
break;
case 'd':
case 'D':
printf("1101");
break;
case 'e':
case 'E':
printf("1110");
break;
case 'f':
case 'F':
printf("1111");
break;
default:
printf("Entered number is not Hexadecimal.Printed value is not correct.");
break;
}

return 0;
}

[/code]