Example
Input
Input character: C
Output
'C' is uppercase alphabet
/**
* C program to check whether a character is uppercase or lowercase
*/
#include <stdio.h>
int main()
{
char ch;
/* Input character from user */
printf("Enter any character: ");
scanf("%c", &ch);
if(ch >= 'A' && ch <= 'Z')
{
printf("'%c' is uppercase alphabet.", ch);
}
else if(ch >= 'a' && ch <= 'z')
{
printf("'%c' is lowercase alphabet.", ch);
}
else
{
printf("'%c' is not an alphabet.", ch);
}
return 0;
}
/*
Output :
Enter any character: C
'C' is uppercase alphabet.
*/
Program to check uppercase or lowercase characters using library functions
/**
* C program to check whether a character is uppercase
* or lowercase using inbuilt library functions
*/
#include <stdio.h>
#include <ctype.h> /* Used for isupper() and islower() */
int main()
{
char ch;
/* Input character from user */
printf("Enter any character: ");
scanf("%c", &ch);
if(isupper(ch))
{
printf("'%c' is uppercase alphabet.", ch);
}
else if(islower(ch))
{
printf("'%c' is lowercase alphabet.", ch);
}
else
{
printf("'%c' is not an alphabet.", ch);
}
return 0;
}
/*
Output :
Enter any character: C
'C' is uppercase alphabet.
*/