View All C Programs

 Previews Example  View All C Programs Next Example 

Program to Check Whether a Character is an Alphabet or not in C

This program takes a character from user and checks whether that character is an alphabet or not.
#include <stdio.h>
int main()
{
    char c;
    printf("Enter a character: ");
    scanf("%c",&c);
    if( (c>='a'&& c<='z') || (c>='A' && c<='Z'))
       printf("%c is an alphabet.",c);
    else
       printf("%c is not an alphabet.",c);
    return 0;
}   
Result
Enter a character: #
# is not an alphabet

Enter a character: M
M is an alphabet