Header Ads Widget

C++ Program to take the value from the user as input any alphabet and check whether it is vowel or consonant Using the switch statement.

 

 C++  Program to take the value from the user as input any alphabet and check whether it is vowel or consonant Using the switch statement. 

Given a character , write a program to check whether it is vowel or consonant by using switch case . Vowel are (a, e , i , o , u , A , E , I , O , U)   . 

Sample input
a
Sample output
Vowel

C++  Program to take the value from the user as input any alphabet and check whether it is vowel or consonant Using the switch statement. 

The objective of the code is to check whether character is vowel or consonant based by using switch case .

Code(C++):-

#include <iostream>
using namespace std;
int main() {
    char cha;
cout<<"Enter the Character\n";
cin>>cha;
int ch=(cha=='a'|| cha=='e' || cha=='i' || cha=='o' || cha=='u' || cha=='A'
|| cha=='E' || cha=='I' || cha=='O' || cha=='U');
switch(ch)
{
case 1:cout<<"Vowel ";
break;
case 0:cout<<"Consonant";
break;
}
}

Output:-

Enter the Character
a
Vowel


Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-