C++ Program to Check Vowel or Consonant Using If Else

C++ program to check vowel or consonant. Checking the word is vowel or consonant in c++ program and print the whether the letter is vowel or not

#include <iostream>
using namespace std;
int main()
{
char c;
bool lowercase, Uppercase;
cout << "Enter the letter";
cin >> c;
lowercase = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
Uppercase = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
if (!isalpha(c))
cout<< "Its not alphabet";
else if (lowercase || Uppercase)
cout << c << " is a vowel";
else
cout << c << " is a consonant";

return 0;
}

 

Output:

Enter the letter

f f is a consonant

Vowel in C++ Program

A whole number that may be split into two equal whole numbers by two. Even numbers are zero, two, four, six, and eight. 

aaaaa There! You just made a vowel sound. An open sound is represented by a vowel, which is a letter. 

In the English language, there are six vowels: a, e, I o, u, and y. 

The letter Y is sometimes a vowel, like in the word narrative, but it may also be a consonant, as in the word yes.

Consonant in C++

A consonant is a sound that is not a vowel in speech. It also refers to the letters of the alphabet that represent certain sounds: 

consonants include Z, B, T, G, and H. All non-vowel sounds, or their equivalent letters, are consonants: A, E, I, O, U, and occasionally Y are not consonants. H and T are consonants in the hat.

Namespace in C++

A namespace is a declarative region that provides a scope to the names of types, functions, and variables contained within it. 

Namespaces are used to organise code into logical groups and to avoid name collisions, which can occur when your code base contains multiple libraries.