← printf, scanf & Overflow

Char Arithmetic

hard

Read a single lowercase letter and print its uppercase form, using arithmetic on the character’s numeric value – not a library helper like toupper.

This is the payoff of “a char is just a small integer”: 'a', 'b', … 'z' are consecutive integer values in ASCII, and so are 'A' … 'Z', with a fixed gap between the two blocks. 'a' - 'A' computes that gap as a number (32, though you shouldn’t need to know that – write it in terms of the character constants, not the literal 32, so the code documents why it works). Subtracting the gap from any lowercase letter lands you on the matching uppercase letter.

Your solution

"Run" uses the sample stdin ("a"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution