Question : Write a C++ program to Check Whether Character is Vowel or Constant ?
Explain: C++ Question about check input from user then program tells us which given char is Vowel or Constant. We will used simple If-else statement for resolving solution.
Solution:
/************************************************************
C++ Program for check Vowel or Constant character using if else
*************************************************************
***************** By cpplanguage.com *********************/
#include <iostream>
using namespace std;
int main()
{
char character;
cout << "Enter an alphabet: ";
// Getting Input as char
cin >> ch;
// check all vowel list with upper and lower both if true then vowel otherwise constant char
if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' )
{
cout << ch << " is a vowel."<<endl;
}
else
{
cout << ch << " is a consonant."<<endl;
}
return 0;
}
Output:
Explain: C++ Question about check input from user then program tells us which given char is Vowel or Constant. We will used simple If-else statement for resolving solution.
Solution:
/************************************************************
C++ Program for check Vowel or Constant character using if else
*************************************************************
***************** By cpplanguage.com *********************/
#include <iostream>
using namespace std;
int main()
{
char character;
cout << "Enter an alphabet: ";
// Getting Input as char
cin >> ch;
// check all vowel list with upper and lower both if true then vowel otherwise constant char
if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' )
{
cout << ch << " is a vowel."<<endl;
}
else
{
cout << ch << " is a consonant."<<endl;
}
return 0;
}
Output: