Question
Using ternary operator check a character is Vowel or Consonant.
Solution
β Verified
#include <stdio.h>
int main() {
char ch;
printf("Enter a Character: \n");
scanf("%c", &ch);
((ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') || (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')) ? printf("Vowel\n") : printf("Consonant\n");
return 0;
}
Click here to download practice questions on
Ternary Operator