Header Ads Widget

C++ program to input any alphabet and check whether it is vowel or consonant

 

 C++ program to input any alphabet and check whether it is vowel or consonant

Given a character , write a program to check whether it is vowel or consonant . Vowels are (a ,e ,i , o , u ) and (  A , E , I , O , U) and except these characters all are consonants .

Sample input

f

Sample output

f is consonant

 C++ program to input any alphabet and check whether it is vowel or consonant

The objective of the code is to check whether the character is vowel or consonants . 

Code(C++):-

#include <bits/stdc++.h>
using namespace std;

int main()
{
   char ch;
cin>>ch;
if(ch=='A'|| ch=='E'|| ch=='I'|| ch=='O'|| ch=='U'|| ch=='a'
||ch=='e'|| ch=='i'||ch=='o'|| ch=='u')
cout<<ch<<" is vowel";
else
cout<<ch<<" is consonant";
return 0;
}

Output:-


f
f is consonants

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:-