C program to check alphabet, digit or special symbol using ASCII value and conditional operator.
C program to check alphabet, digit or special symbol using ASCII value and conditional operator
#include <stdio.h>
int main()
{
char ch;
printf("\n Enter any character: ");
scanf("%c", &ch);
((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))?
printf("%c It is Alphabet",ch) :
(ch >= 48 && ch <= 57)?
printf("%c It is digit",ch) :
printf("%c It is Special Character",ch);
getch();
return 0;
}
Output:
Enter any character: p
p It is Alphabet
Enter any character: 8
8 It is digit
Enter any character: $
$ It is Special Character