C Program to Check Character is Alphabet or not. In this article, we are going to write a c program to check whether a character is alphabetical or not.
Table of Contents
How to Check if a Character is an Alphabet in C
To check if a character is alphabetically in C, We can use the C language standard library function isalpha()
from <ctype.h> or we can manually check if the character falls within the ranges of a-z or A-Z.
C Program to Check Alphabet(manually)
#include <stdio.h>
void main()
{
char ch;
printf("Enter the character ");
scanf("%c", &ch);
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
{
printf("%c is an alphabet", ch);
}
else
{
printf("%c is not an alphabet", ch);
}
}
Output
The above C program checks if the character falls within the ASCII range for lower case letters (a-z) or upper case letters (A-Z).
This program is a basic example of how to determine if a character is part of the English alphabet using C. It demonstrates conditional logic and the use of ASCII value range to classify characters.
Happy Coding & Learning
1 thought on “C Program to Check Character is Alphabet or not”