Search
 
SCRIPT & CODE EXAMPLE
 

CPP

vowel and consonant program in c++ using if else

#include <iostream>
using namespace std;

int main() {
    char c;
    bool 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');

    // show error message if c is not an alphabet
    if (!isalpha(c))
      printf("Error! Non-alphabetic character.");
    else if (isLowercaseVowel || isUppercaseVowel)
        cout << c << " is a vowel.";
    else
        cout << c << " is a consonant.";

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: reading matrix from text file in c++ and adding them and then storing them in oother c++ file 
Cpp :: Z-function 
Cpp :: grepper users assemble 
Cpp :: softwareegg.courses4u 
Cpp :: ternary operator rsut 
Cpp :: codeforces problem 1700A solution in c++ 
Cpp :: Operatore ternario c++ 
Cpp :: sjfoajf;klsjflasdkfjk;lasjfjajkf;dslafjdjalkkkjakkkkkkkkkkkkkkkkfaWZdfbhjkkkk gauds 
Cpp :: c++ to c code converter 
Cpp :: start google 
Cpp :: file transfer socat 
Cpp :: foo foo little dogs 
Cpp :: Difference Array | Range update query in O 
Cpp :: KUNG FU HUSTLE 
Cpp :: assign array to array 
Cpp :: c++ poitner 
Cpp :: cpp Case value is not a constant expression 
Cpp :: 28+152+28+38+114 
Cpp :: print an array c++ 
Cpp :: how to adjust and delete memory in c, c++ 
Cpp :: Make them equal codechef solution in c++ 
Cpp :: c++ create a vecto 
Cpp :: convert c to C language 
Cpp :: ala vida 
Cpp :: std::throw_with_nested 
Cpp :: assert warning c++ 
Cpp :: npm wasm 
Cpp :: how to store array of string with spaces in c++ stl 
Cpp :: kruskal algorithm in c++ 
Cpp :: c++ to c converter online free 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =