C Program to check for an alphabet or not – In this particular article, we will detail in on the standard method used to check for an alphabet or not in C programming.
Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself.
As you can see, funnily enough, these are the alphabet in the English language. There are a total of 26 of them.
Thus, the way to check for an alphabet is as follows:
Using Standard Method
1)Read the entered character and store it in the variable ‘ch’ which is a character data type.
2)Check whether the ASCII value of the entered character is in the range between 65 to 90 or 97 to 122 or not using “if “condition.
3)If it is in the range then it prints “alphabet” otherwise prints “not alphabet”.
1 2 3 4 5 6 7 8 9 10 11 |
#include<stdio.h> int main() { char ch; printf("enter chartacter"); scanf("%c",&ch); if(ch>=65 && ch<=90 || ch>=97 && ch<=122) printf("alphabet"); else printf("not aphabet"); } |