Question

Using ternary operator check a character is Vowel or Consonant.

Updated on May 31, 2025 | By Learnzy Admin | πŸ‘οΈ Views: 169 students

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;
}
Was this solution helpful? 33
Click here to download practice questions on Ternary Operator

More Questions on Ternary Operator

Question 1

Find the smallest of two numbers using ternary opeartor


View solution
Question 2

Check a Person is Eligible to Vote or not using ternary operator


View solution
Question 3

Assign Grade using nested ternary operator


View solution
Question 4

Check if a Number is Positive, Negative or Zero Using Nested Ternary


View solution
Question 5

Find Maximum of Two Numbers using ternary operator


View solution