/* Program 3-11 shows packed BCD-to-ASCII conversion using logical bitwise operators in C */ #include main() { unsigned char mybcd=0x29; /* declare a BCD number in hex */ unsigned char asci_1; unsigned char asci_2; asci_1=mybcd&0x0f; /* mask the upper four bits */ asci_1=asci_1|0x30; /* make it an ASCII character */ asci_2=asci_2>>4; /* shift it right 4 times */ asci_2=asci_2|0x30; /* make it an ASCII character */ printf("BCD data %X is %c , %c in ASCII\n",mybcd,asci_1,asci_2); printf("My BCD data is %c if not converted to ASCII\n",mybcd); }