- Write a C program to check whether a character is vowel or consonant using switch case statement.
- How to find whether an alphabet is vowel or not using switch case statement.
Required Knowledge
- C printf and scanf functions
- Switch case statement in C
A vowel is the alphabets that represents a speech sound created by the relatively free passage of breath through the larynx and oral cavity. Letters that are not vowels are consonants. English has five proper vowel letters (A, E, I, O, U) all alphabets except these characters are consonants.
C program to check whether a character is vowel or consonant using switch statement
#include <stdio.h> int main() { char c; /* * Take a character as input form user */ printf("Enter an Alphabet\n"); scanf("%c", &c); /* Check If input alphabet is vowel or not using switch statement */ switch(c) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("%c is VOWEL", c); break; default: printf("%c is CONSONANT", c); } return 0; }
Output
Enter an Alphabet e e is VOWEL
Enter an Alphabet Z Z is CONSONANT