C Program to Check Whether a Character is Alphabet or not
Program
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
clrscr();
printf("Enter any character: ");
scanf("%c", &ch);
if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
{
printf("%c is ALPHABET.", ch);
}
else
{
printf("%c is NOT ALPHABET.", ch);
}
getch();
return(0);
}
Output of above program:
Run 1: ---------- Enter any character: q ↲ q is ALPHABET. Run 2: ---------- Enter any character: G ↲ G is ALPHABET. Run 3: ---------- Enter any character: % ↲ % is NOT ALPHABET. Run 4: ---------- Enter any character: 9 ↲ 9 is NOT ALPHABET. Note: ↲ indicates ENTER is pressed.