(Hexadecimal to Binary Converter)
#include
#include
#include
void main()
{
char z[5],c;
int i=0;
clrscr();
printf("Enter a hexadecimal no.");
printf("
Number will be accepted if you press Ctrl-Z & then ENTER after inputting no.");
printf("
NUMBER:- " );
while ((c=getchar())!=EOF)
{
printf(" ");
if (c=='1')
printf("0001");
else if (c=='2')
printf("0010");
else if (c=='3')
printf("0011");
else if (c=='4')
printf("0100");
else if (c=='5')
printf("0101");
else if (c=='6')
printf("0110");
else if (c=='7')
printf("0111");
else if (c=='8')
printf("1000");
else if (c=='9')
printf("1001");
else if (c=='A'||c=='a')
printf("1010");
else if (c=='B'||c=='b')
printf("1011");
else if (c=='C'||c=='c')
printf("1100");
else if (c=='D'||c=='d')
printf("1101");
else if (c=='E'||c=='e')
printf("1110");
else if (c=='F'||c=='f')
printf("1111");
else
{ printf("ERROR");
getch();
exit(0); }
}
printf("
is its binary equivalent.");
getch();
}