Home / Programs / Write a program that checks whether a character entered by the user is a vowel or not (using switch case)
Programming Example

Write a program that checks whether a character entered by the user is a vowel or not (using switch case)

👁 1,183 Views
💻 Practical Program
📘 Step by Step Learning
Write a program that checks whether a character entered by the user is a vowel or not

Program Code

#include <stdio.h>
int main(void)
{
	char c;
	printf("Enter a character: ");
	scanf("%c", &c);
	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 always a vowel!\n", c);
						break;
		case 'y': case 'Y':
						printf("%c is sometimes a vowel!\n", c);
						break;
		default:
						printf("%c is not a vowel!\n", c);

	}
	getch();
	return 0;
}

Output

<b>Output 1:</b>
Enter a character: a
a is always a vowel!


<b>Output 2:</b>
Enter a character: C
C is not a vowel!

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.