Explore a little.C ProgrammingC++HTMLVisual BasicSystem AnalysisE-CommerceBCA Notes
LEARN SOMETHING NEW

C++ Program to Check Whether a character is Vowel or Consonant

Read4BCA learning libraryFree access

C++ Program to Check Whether a character is Vowel or Consonant

//C++ Program to Check Whether a character is Vowel or Consonant.
//header files
#include<iostream.h>
#include<conio.h>

void main()
{

clrscr();
char c;
int isLowercaseVowel, isUppercaseVowel;
cout << "Enter an alphabet: ";
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 << c << " is a vowel.";

}
else
{

cout << c << " is a consonant.";

}
getch();

}

Output

C++ Program to Check Whether a character is Vowel or Consonant example

You can also see a video how to run this program

This lesson preserves the original Read4BCA material. Some programming examples use older tools and syntax. View original page.