C program to check vowel or consonant conditional operator
C program to check vowel or consonant using conditional operator
#include <stdio.h>
int main()
{
char ch;
printf("Enter any character: ");
scanf("%c", &ch);
(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' ||
ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')?
printf("\n %c It is vowel",ch):
((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))?
printf("\n %c It is consonant",ch):
printf("\n %c It is not alphabet",ch);
return 0;
}
Output:
Enter any character: o
o It is vowel
Enter any character: p
p It is consonant
Enter any character: 8
8 It is not alphabet