#include #include #include //for the function toupper using namespace std; /* Use "bitwise and" to change the character lowercase 'a' to uppercase 'A'. (We're really changing the number 97 to 65.) The "bitwise and" turns off bit number 5 of the character c, converting it from lower to uppercase. 01100001 The ASCII code of lowercase 'a' is 97. & 11011111 The mask 0xDF has 0 in bit position 5, and 1 everywhere else. ---------- 01000001 The ASCII code of uppercase 'A' is 65. */ int main() { char c {'a'}; //Put 01100001 into c (in decimal, that's 97) cout << c << "\n"; c &= 0xDF; //means c = c & 0xDF; cout << c << "\n\n"; char d {'b'}; //Put 01100010 into d (in decimal, that's 98) cout << d << "\n"; d = toupper(d); //changes d to 01000010 (in decimal, that's 66) cout << d << "\n"; return EXIT_SUCCESS; }