C program to check for an alphabet, digit or special character – In this article, we will detail in on the standard method of determining whether any character is an alphabet, digit or a special character.
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, only the standard method is used to define the same.
There are three types of characters used very popularly in the world of information namely:
- Special Characters
All three of these are extremely important in order to move ahead with the scheme of things.
As you can see, everything that is given here comes under the mentioned three categories.
Thus, the way to check for the same in C programming is as follows:
Using Standard Method
1)Read the entered character.
2)If the entered character ASCII value is between 65 to 90 (or) 97 to 122, then it prints “character is alphabet”.otherwise, it checks the next if condition.
3)If the ASCII value is between 48 to 57, then it prints “character is number”.Otherwise, it prints “special character”.
printf("enter character :");
if(ch>=65 && ch<=90 || ch>=97 && ch<=122)
printf("character is alphabet");
else if(ch>=48 && ch<=57)
printf("character is number");
the character is number
enter character :a
character is alphabet