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

Is java as fast as c++?

810


What is :: operator in c++?

800


To what does “event-driven” refer?

830


Can we call C++ OOPS? and Why

421


What does flush do c++?

806


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

757


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

815


How to reverse a string in C++

551


What is c++ namespace?

959


What is null and void pointer?

808


What are the benefits of oop?

872


This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.

1860


Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

3917


What is an accessor in c++?

833


Can you sort a set c++?

771