Checking for Vowels or Not in C Programming


This program is a basic example of switch case statement in C programming. It takes a character input from the user and checks if the entered character is a vowel or not.

The switch statement takes a variable, in this case it is the character 'c', and compares it to the different cases specified in the program. If the entered character matches any of the cases 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U', the program will execute the code inside the corresponding case and print "c is a Vowel" where c is the entered character. If none of the cases match the entered character, the program will execute the code inside the default case and print "c is not a Vowel".

This program uses the switch-case statement to check the entered character, it is efficient and easy to read and understand in comparison with if-else statement.


Source Code

/*
Write a program to find the given character is  vowels or not
using switch case. aeiou
*/
 
#include<stdio.h>
 
int main()
{
 char c;
 printf("\nEnter The Character : ");
 scanf("%c",&c);
 switch(c)
 {
 case 'a':
 case 'e':
 case 'i':
 case 'o':
 case 'u':
 case 'A':
 case 'E':
 case 'I':
 case 'O':
 case 'U':
    printf("%c is a Vowel",c);
    break;
 default:
    printf("%c is not a Vowel",c);
    break;
 }
 return 0;
}
 
To download raw file Click Here

Output

Enter The Character : U
U is a Vowel
Enter The Character : T T is not a Vowel

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C