C++ Online Compiler
Example: C++ program to check vowel or consonant using if else, It will either vowel or consonant
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to check vowel or consonant using if else, It will either vowel or consonant #include <bits/stdc++.h> #include <cctype> // this header file loaded for check the charcters using namespace std; int main() { char random_character; int lowercase = 0, uppercase = 0; cout << "Enter a character to check: "; cin >> random_character; // isalpha() function will check // whether character is alphabetic or non-alphabetic if (random_character && isalpha(random_character)) { // it will be return 1 // if input character matched with these small characters lowercase = random_character == 'a' || random_character == 'e' || random_character == 'i' || random_character == 'o' || random_character == 'u'; // it will be return 1 // if input character matched with these capital characters uppercase = random_character == 'A' || random_character == 'E' || random_character == 'I' || random_character == 'O' || random_character == 'U'; if (lowercase || uppercase) cout << "\n'" << random_character << "' is a vowel character.\n"; else cout << "\n'" << random_character << "' is a consonant character.\n"; } else { cout << "\nSorry, You entered Non-Alphabetic character!\n"; } return 0; }
K
Output
Clear
ADVERTISEMENTS