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

Get me an image implementation program.

1563


Is c++ a good first language to learn?

580


What is an interface in oop?

599


What is a storage class?

649


Explain the FOR loop with a help of a code.

579






Which bit wise operator is suitable for turning off a particular bit in a number?

647


How will you print a list of all unique words from a string which may contain repeated words?

547


Is map ordered c++?

596


What is a function in oop?

635


Is c++ a dying language?

591


How does java differ from c and c++?

546


How would you use the functions memcpy(), memset(), memmove()?

626


What are exceptions c++?

599


By using c++ with an example describe linked list?

607


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

621