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 doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

576


What is setiosflags c++?

537


Is c++ high level programming language?

681


Which software is best for programming?

666


What is the use of register keyword with the variables?

551






Is there a sort function in c++?

553


What is meant by oops concept?

616


What are abstract data types in c++?

540


What is the difference between #import and #include?

555


Tell me about virtual function

546


What are arrays c++?

612


Whats oop mean?

601


What is meaning of in c++?

675


Why is the function main() special?

631


Explain data encapsulation?

612