ตรวจสอบว่าตัวอักษรที่ให้มาเป็นสระ (a,e,i,o,u) หรือพยัญชนะ
ตัวอย่าง: 'c' → Consonant, 'e' → Vowel
ตัวอย่างโค้ด C++
#include <iostream>
using namespace std;
void is_vowel(char x) {
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u')
cout << "Vowel" << endl;
else
cout << "Consonant" << endl;
}
int main() {
is_vowel('c');
is_vowel('e');
return 0;
}
Output
Consonant Vowel