char mystring[] ="CSc 116, Low Level Programming Language"; /* C program to demonstrate bitwise operations & AND | Inclusive OR ^ Exclusive OR (XOR) ~ NOT (note use for AND mask, flipping all bits) Lin Jensen 23 October 2006 22 February 3 new versions of the string will be printed all upper case all lower case case reversed */ #include int main() { char caps[40]; char lowc[40]; char goofy[40]; char *orig = mystring; char *up = caps; char *down = lowc; char *chg = goofy; char ch; do { ch = *orig++; if (ch >='A') /* assume letter */ { *up++ = ch & ~0x20; /* 0xdf; AND case bit 0 for upper case*/ *down++ = ch | 0x20; /* OR, case bit 1 for lower case*/ *chg++ = ch ^ 0x20; /* XOR flips case bit */ } else /* just copy */ { *up++ = ch; *down++ = ch; *chg++ = ch; } } while (ch); puts(mystring); /* print each string as a line */ puts(caps); puts(lowc); puts(goofy); return 0; }