The letters A-Z are next to each other in any character set. See the ASCII table, for instance: http://www.asciitable.com/
So by subtracting 'A', you get the alphabet index for an uppercase character, i.e. 0 for A, 1 for B and 25 for Z.
This is then used as an array index to increase the count for that particular letter.