Home C Programming Language / 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,185 Views
💻 Practical Program
📘 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;
}

                        

🖥 Program 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
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.