Definition:
A vowel is one of the five English letters: A, E, I, O, U (or a, e, i, o, u). If the entered character matches any vowel, the program displays "It's a vowel". Otherwise, it displays "It's not a vowel".
Explanation:
switch statement compares the entered character with each vowel (a, e, i, o, u).default statement executes and displays "It's not a vowel".break statement stops the execution after a matching case is found.
Explanation: This program accepts a character from the user and checks whether it is a vowel or not using the switch statement.
#include <stdio.h> #include <conio.h> main() { char k; clrscr(); printf("Enter a Character : "); scanf(" %c",&k); switch(k) { case 'A': case 'E': case 'I': case 'O': case 'U': printf("\nIt's a vowel"); break; default: printf("\nIt's not a vowel"); } getch(); }
Output:
switch statement to check whether the entered character is a lowercase vowel or not.switch statement.'a', 'e', 'i', 'o', and 'u'. If none of these cases match, display "Not a Lowercase Vowel".
#include <stdio.h> #include <conio.h> main() { char ch; clrscr(); printf("Enter a Lowercase Character : "); scanf(" %c",&ch); switch(ch) { case 'a': case 'e': case 'i': case 'o': case 'u': printf("\nLowercase Vowel"); break; default: printf("\nNot a Lowercase Vowel"); } getch(); }
switch statement to check whether it is one of the five lowercase vowels. If the entered character is not a lowercase vowel, the default case displays "Not a Lowercase Vowel".