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


Please Help Members By Posting Answers For Below Questions

What is c++ mutable?

698


What are oops methods?

562


What are built-in functions? What is the syntax for the definition?

564


Are polymorphisms mutations?

693


what are Access specifiers in C++ class? What are the types?

622






Can char be a number c++?

587


What is the difference between set and map in c++?

600


Out of fgets() and gets() which function is safe to use?

638


List the advantages of inheritance.

638


What is difference between array and vector in c++?

554


Can union be self referenced?

569


Difference between pointer to constant and constant pointer to a constant. Give example.

635


Can I learn c++ without c?

599


What is overloading in oop?

572


What do you mean by vtable and vptr in c++?

619