C Program To Check Character is Alphabet or Digit
Learn How To Check Character is Alphabet or Digit in C Programming Language. We have listed two different methods for this program. The first method makes use of ASCII values and the second method uses Library functions.
The First Method makes use of ASCII Values. It checks for particular range of ASCII Values. The Second method consists of Built-In Library Functions such as isalpha(), isdigit() which are declared under <ctype.h> Header file.
Also Read: C Program To Check ASCII Values and Character
Method 1: C Program To Check Character is Alphabet or Digit using ASCII Values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<stdio.h> void main() { char ch; printf("\nEnter A Character:\t"); scanf("%c", &ch); if((ch >= 65 && ch <= 91) || (ch >= 97 && ch <= 123)) printf("\n%c is a Alphabet\n", ch); else if(ch >= 48 && ch <= 57) printf("\n%c is a Digit\n", ch); else printf("\n%c is a Symbol\n", ch); } |
Method 2: C Program To Check if Character is an Alphabet or Integr using Library Functions
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<stdio.h> #include<ctype.h> void main() { char ch; printf("\nEnter A Character:\t"); scanf("%c", &ch); if(isalpha(ch)) printf("\n%c is a Alphabet\n", ch); else if(isdigit(ch)) printf("\n%c is a Digit\n", ch); } |
Output

Also Read: C Program To Count Occurrence of Element in Array
If you have any compilation errors or doubts in this C Program To Check if a Character is Alphabet or Digit, let us know about in the Comment Section below.