C examples for Data Type:char
Use toupper() and the tolower() functions to convert a character to uppercase and lowercase, respectively.
#include <stdio.h> #include <ctype.h> int main(void) { char letter = 0; // Stores a character printf("Enter an uppercase letter:"); // Prompt for input scanf("%c", &letter); // Read a character if(isalpha(letter) && isupper(letter)) printf("You entered an uppercase %c.\n", tolower(letter)); else/*from w w w. j a v a 2s . co m*/ printf("You did not enter an uppercase letter.\n"); return 0; }