C++ Program to Check Whether a character is Vowel or Consonant. In this example, if...else statement is used to check whether an alphabet entered by the user is a vowel or a constant. To understand this example, you should have the knowledge of following C++ programming topics: C++ if, if...else and Nested if...else Five alphabets a, e, i, o and u are known as vowels. All other alphabets except these 5 alphabets are known are consonants. This program assumes that the user will always enter an alphabet. Example: Check Vowel or a Consonant Manually #include <iostream> using namespace std ; int main () { 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'
c++ sample codes to beginners
ReplyDeletecplusplus samples | Computing sum with template arrays for vector