Write a C++ Program to Check Whether a character is Vowel or Consonant.

Answer Posted / hr

Solution:
/* C++ Program to Check Whether a character is Vowel or Consonant */
#include <iostream>
using namespace std;
int main()
{
char c;
int isLowercaseVowel, isUppercaseVowel;
cout << "Enter any character to check :: ";
cin >> c;
// evaluates to 1 (true) if c is a lowercase vowel
isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
// evaluates to 1 (true) if c is an uppercase vowel
isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
// evaluates to 1 (true) if either isLowercaseVowel or isUppercaseVowel is true
if (isLowercaseVowel || isUppercaseVowel)
{
cout<<"
The Entered Character [ "<<c<<" ] is a Vowel.
";
}
else
{
cout<<"
The Entered Character [ "<<c<<" ] is a Consonant.
";
}
return 0;
}
Output:
/* C++ Program to Check Whether a character is Vowel or Consonant */
Enter any character to check :: u
The Entered Character [ u ] is a Vowel.
Process returned 0

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

1892


What is prototype in c++ with example?

745


What is a static element?

809


Explain how the virtual base class is different from the conventional base classes of the opps.

908


write a corrected statement in c++ so that the statement will work properly. x = y = z + 3a;

1653


What character terminates all character array strings a) b) . c) END

979


Difference between Abstraction and encapsulation in C++?

835


What is meant by entry controlled loop? What all C++ loops are exit controlled?

836


what are the realtime excercises in C++?

2551


What are issues if we mix new and free in C++?

509


What is c++ vb?

849


Which is the best c++ compiler?

794


When did c++ add stl?

954


What are the advantages of c++? Explain

800


What is the full name of logo?

844