How to check the character is vowel or not in c++


The following program use a cascading if-else construct to determine if the input  character is a vowel, else it print an  appropriate message.


#include<iostream.h>
  int main()
{
 char in_chr;

 cout << "Enter a character in lowercase"<<endl;

cin >> in_chr;

if (in_chr == 'a')
         
                 cout << endl << "vowel a"<<endl;

else if (in_chr =='e')
 
                 cout << endl << "vowel e" << endl;


else if (in_chr == 'i')
 
                 cout << endl << "vowel i" << endl;

else if (in_chr =='o')
 
                  cout << endl << "vowel o" << endl;


else if (in_chr =='u')
  
                  cout << endl << "vowel u" << endl;

else

                  cout << endl << "The character is not a vowel" << endl;
       
                 return 0;
}

0 comments:

Post a Comment