Five problems about characters that need a condition: what kind of character is it, and where does it sit in the alphabet?
Last week's character codes plus this week's conditions are all they need:
- Is it a lowercase letter? is
c >= 'a' && c <= 'z'; the same with'A'and'Z'for uppercase,'0'and'9'for digits. c - 'a'is the position of a lowercase letter (0 for'a'), andchar('a' + k)is the letter at positionk.- Upper and lower case are 32 apart:
char(c - 32)andchar(c + 32). - Watch the ends of the alphabet: the letter after
'z'and the one before'a'need a condition of their own.