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
Are strings immutable in c++?
What is the difference between delegation and implemented-in-terms-of?
How does stack look in function calls? When does stack overflow? What can you do to remedy it?
What are c++ data types?
What is a hashmap c++?
What are issues if we mix new and free in C++?
Define what is constructor?
Can we get the value of ios format flags?
What exactly is polymorphism?
what is difference between class template and template class?
What are oops functions?
Tell me can a pure virtual function have an implementation?
what you know about c++?
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?