Test letter range
#include <stdio.h> int main(void) { char letter = 0; // Stores an input character printf("Enter an upper case letter:"); // Prompt for input scanf(" %c", &letter); // Read the input character if((letter >= 'A') && (letter <= 'Z')) // Verify uppercase letter {/*from w w w .jav a 2s.co m*/ letter += 'a'-'A'; // Convert to lowercase printf("You entered an uppercase %c.\n", letter); } else printf("You did not enter an uppercase letter.\n"); return 0; }
The following expressing converts uppercase to lowercase:
letter += 'a'-'A'; // Convert to lowercase