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
what's the basic's in dot net
Can non-public members of another instance of the class be retrieved by the method of the same class?
What is the latest version on c++?
Which coding certification is best?
Can we use THIS Pointer in static function – Reason in C++?
Is there any error below, its a code to delete all entires from a map #include
What are the various types of stl containers?
Is the declaration of a class its interface or its implementation?
Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What is c++ and its features?
Can you declare an array without a size in c++?
What is coupling in oop?
What is the limitation of cin while taking input for character array?
What do you mean by translation unit?
What is isdigit c++?