C - Use function to check uppercase and lowercase letter

Introduction

ctype.h standard header file has functions isalpha(), isupper(), and islower() that test the character you pass as the argument.

They return true if the argument is alphabetic, uppercase, or lowercase, respectively.

It also declares the toupper() and the tolower() functions to convert a character to uppercase and lowercase, respectively.

Demo

#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   www  .  j  av a2 s .c o  m*/
        printf("You did not enter an uppercase letter.\n");
      return 0;
}

Result