Monday, 7 March 2016

C++ Program For Check Character Is Vowel Or Not Using If Else

Problem :- Write A C++ Program For Check Character Is Vowel Or Not Using If Else Statement .

Logic :- As we know that there are 26 Character in 
English Language and only 5 Vowel Or 21 Constant ,We also know that our keyboard support only two types of English Character Capital Of Small So only we need to compare with only 5 Character .
5 Vowels are A E I O U and rest are Constant . So just we need to compare with Capital and Small Both .
If you got the Logic then try to solve the given Problem  

Try Yourself C Program To Check Number Is Positive Or Negative

Solution :-

#include<bits/stdc++.h>
using namespace std;
int main()
{
  //Ghanendra Yadav
    char ch;
    
cout << "Enter an Alphabet :\n";
    cin >> ch;
    
    if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||ch=='o'||ch=='O'||ch=='u'||ch=='U')
  {
        cout << ch << " Is A Vowel .\n";
    }
    else
  {
        cout << ch << " Is Not A Vowel.\n";
    }
   
    return 0;
}

Output:-

C++ Program For Check Character Is Vowel Or Not Using If Else

2 comments:
Write comments

Recommended Posts × +