find Alphabet is vowel or consonant
Table of Contents
In this article, we will discuss the concept of Program to check Vowel or Consonant using switch in C
In this post, we are going to learn how to write a program to check whether given English alphabet is Vowel or consonant using switch case statement in C language
In this code, we are going to learn how to write a program to check the given English alphabet is Vowel or consonant using switch case statement in C language
Program 1
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch;//declare character variable
printf("Enter any Alphabets: ");
scanf("%c",&ch);
switch(ch){
//Check lower case vowel
case 'a':
printf("%c is Vowel",ch);
break;
case 'e':
printf("%c is Vowel",ch);
break;
case 'i':
printf("%c is Vowel",ch);
break;
case 'o':
printf("%c is Vowel",ch);
break;
case 'u':
printf("%c is Vowel",ch);
break;
//Check upper case vowel
case 'A':
printf("%c is Vowel",ch);
break;
case 'E':
printf("%c is Vowel",ch);
break;
case 'I':
printf("%c is Vowel",ch);
break;
case 'O':
printf("%c is Vowel",ch);
break;
case 'U':
printf("%c is Vowel",ch);
break;
default:
printf("%c is consonant",ch);
break;
}
getch();
return 0;
} When the code is executed, it produces the following result
Case 1
Enter any Alphabets: A A is Vowel
Case 2
Enter any Alphabets: i i is Vowel
Case 3
Enter any Alphabets: M M is consonant
In this code, we are going to learn how to write a program to check the given English alphabet is Vowel or consonant using switch case statement in C language
Program 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch;
printf("Enter any Alphabets: ");
scanf("%c",&ch);
switch(ch){
//Check lower case vowel
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
//Check upper case vowel
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("%c is Vowel",ch);
break;
default:
printf("%c is consonant",ch);
break;
}
getch();
return 0;
} When the code is executed, it produces the following result
Case 1
Enter any Alphabets: E E is Vowel
Case 2
Enter any Alphabets: u u is Vowel
Case3
Enter any Alphabets: K K is consonant
Suggested post
Similar post
Java program to print all alphabets in given range
C program to print all alphabets in given range
C++ program to print all alphabets in given range
Java program to print all alphabets using loops
C program to print all alphabets using loops
C++ program to print all alphabets using loops
Java program to check whether a character is Alphabet or Not
C++ program to check whether a character is Alphabet or Not
C program to check whether a character is Alphabet or Not
Python program to check whether a character is Alphabet or Not
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.