/***********************************************/
/* HEXADECIMAL TO BINARY CONVERTER */
/* Source code written by: A. Yavuz Oruç */
/* E-mail: yavuz@eng.umd.edu */
/* Last revised: October 1998 */
/* Input: 4-digit hexadecimal number */
/* Output: 16-bit binary number */
/* */
/***********************************************/
#include <iostream.h>
#include <stdio.h>
#include <limits.h>
void main(void)
{unsigned int r, i;
char binary[16];
while(true)
{
//AYO: Here read a 4-digit hexadecimal number.
printf("\nEnter a 4-digit hexadecimal number: ");
scanf("%04X", &r);
printf("\nYou entered: ");
printf(" "); printf("%04X",r); printf("\n");
for(i = 0; i<= 15; i++) binary[15-i] = (r >> i) % 2;
printf("\nBinary representation of your hexadecimal number is: ");
for(i = 0; i<= 15; i++)
printf("%01d",binary[i]);
printf("\n");
}
}