Check whether a character is an alphabet, digit or special character
Here, you will get and learn the example code to check whether a character is an alphabet, digit or special character in C programming.
Program Code to check character is an alphabet, digit or special character
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<stdio.h> int main() { char c; printf("Input a character: "); scanf("%c", &c); if((c>='a'&& c<='z') || (c>='A' && c<='Z')) printf("%c is an Alphabet",c); else if(c>='0' && c<='9') printf("%c is a Digit",c); else printf("%c is a Special Character",c); return 0; } |
Output 1
Input a character: 5
5 is a Digit
Output 2
Input a character: K
K is an Alphabet
Output 3
Input a character: @
@ is a Special Character
Check out our other C programming Examples