C program to check alphabet, digit or special symbal using conditional operator
C program to check alphabet, digit or special symbal using conditional operator
#include <stdio.h>
int main()
{
char ch;
printf("\n Enter any character: ");
scanf("%c", &ch);
(ch>='a' && ch<='z'||ch>='A' && ch<='Z') ?
printf("%c It is Alphabet",ch) :
(ch>='0'&&ch<='9' ) ?
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