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
Do class declarations end with a semicolon?
Is java a c++?
Do you know what are static and dynamic type checking?
What are main features of oop?
What is lambda in c++?
Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
How would you implement a substr() function that extracts a sub string from a given string?
How do you find out if a linked-list has an end? (I.e. The list is not a cycle)
What are the characteristics of friend functions?
What is c++ array?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
What are the operators in c++?
Are there interfaces in c++?
On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?