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
Plese get me a perfect C++ program for railway/airway reservation with all details.
If class D is derived from a base class B
totoo po ba ang manga aliens!
What is stream in oop?
What is the difference between public, private, and protected inheritance?
What are exceptions c++?
What is difference between data abstraction and encapsulation?
I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?
What is difference between malloc()/free() and new/delete?
Explain what is polymorphism in c++?
Explain the difference between method overriding and method overloading in C++?
write a programe to calculate the simple intrest and compund intrest using by function overlading
What are containers in c++?
Why use of template is better than a base class?
Is there any difference between int [] a and int a [] in c++?