Letter Position
Completed
Read a lowercase letter and print its position in the alphabet (a = 1) and the upper-case letter.
Input
One lowercase letter.
Output
Two lines.
Example
Input
a
Output
1 A
Editor
C
Hints
c - 'a' is 0 for a, 1 for b, ...
The space in " %c" skips any whitespace first.
Solution explanation
Letters have consecutive codes, so subtracting 'a' gives the position.
Show solution
#include <stdio.h>
int main() {
char c;
scanf(" %c", &c);
printf("%d\n", c - 'a' + 1);
printf("%c\n", c - 'a' + 'A');
return 0;
}