/* File: bitop.ch (run in Ch only) Apply bitwise operators to variables with 1 byte. Ch features used: the printing format "%b" and binary constant 0bxxxx */ #include int main() { /* declare variables and initialize with binary numbers */ char a = 0b10110100; char b = 0b11011001, c; /* apply bitwise operators to variables a and b and display the result */ printf("a = 0b%8b\n", a); printf("b = 0b%8b\n", b); c = a & b; printf("a & b = 0b%8b\n", c); c = a | b; printf("a | b = 0b%8b\n", c); c = a ^ b; printf("a ^ b = 0b%8b\n", c); c = b << 1; printf("b << 1 = 0b%8b\n", c); c = a >> 1; printf("a >> 1 = 0b%8b\n", c); c = ~a; printf("~a = 0b%8b\n", c); return 0; }