/* Program 3-10 Repeats Examples 3-5 through 3-11 in C */ #include main() { // Notice the way data is defined in C for Hex format using 0x unsigned char data_1 = 0x35; unsigned int data_2 = 0x504; unsigned int data_3 = 0xDA66; unsigned char data_4= 0x54; unsigned char data_5=0x78; unsigned char data_6=0x37; unsigned char data_7=0x09A; unsigned char temp; unsigned int temp_2; temp=data_1&0x0F; //ANDing printf("\nMasking the upper four bits of %X (hex) we get %X (hex)\n",data_1,temp); temp_2=data_2|data_3; //ORing printf("The result of %X hex ORed with %X hex is %X hex\n",data_2,data_3,temp_2); temp= data_4^data_5; //EX-ORing printf("The results of %X hex EX-ORed with %X hex is %X hex\n",data_4,data_5,temp); temp=~data_6; //INVERTING printf("The result of %X hex inverted is %X hex\n",data_6,temp); temp=data_7>>3; //SHIFTING Right printf("When %X hex is shifted right three times we get %X hex\n",data_7,temp); printf("When %X hex is shifted right four times we get %X hex\n",0x7777,0x7777>>4); temp=(0x6<<4); //SHIFTING Left printf("When %X hex is shifted left %d times we get %X hex\n",0x6,4,temp); }