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 is pass by value & reference.
Can a new be used in place of old mallocq? If yes, why?
Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.
What is ctime c++?
Why Pointers are not used in C++?
Can we use struct in c++?
Comment on c++ standard exceptions?
How do you initialize a string in c++?
What do you understand by a pure virtual member function?
Which bit wise operator is suitable for checking whether a particular bit is on or off?
Define a conversion constructor?
• What are the desirable attributes for memory managment?
How will you execute a stack using a priority queue? (Push and pop should be in O (1)).
How many types of comments are there in c++?
What do you mean by translation unit in c++?