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

Mention the ways in which parameterized can be invoked. Give an example of each.

824


Do you know about latest advancements in C++ ?

887


Can we make any program in c++ without using any header file and what is the shortest program in c++.

867


Are there interfaces in c++?

770


Explain the difference between struct and class in terms of access modifier.

981


Can constructor be static in c++?

884


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

860


How delete [] is different from delete?

806


What is the use of seekg in c++?

819


What is a class template in c++?

824


What is solid in oops?

822


Plese get me a perfect C++ program for railway/airway reservation with all details.

3678


What is byval and byref? What are differences between them?

1967


How come you find out if a linked-list is a cycle or not?

810


What are the types of container classes?

843