I need some help with a code I'm writing. The user inputs some letters, a loop is ran to check if it's a vowel or consonant, then when the user is done it returns the total amount of vowels and consonants.
The problem I'm having is the loop is suppose to stop when the user clicks Ctrl + X, but I can't get it to work. For now as a test I have it stop when the user enters 'z'. Any help would be VERY appreciated!
#include <iostream>
using namespace std;
void is_vowel(int & vowel, int & cons, char ch);
int main(){
int vowel = 0, cons = 0;
char ch = ' ';
cout << "Please enter some letters (Stop with Ctrl + X): ";
while (ch != 'z'){
cin >> ch;
is_vowel(vowel, cons, ch);
}
cout << vowel << endl;
cout << cons << endl;
return 0;
}
void is_vowel(int & vowel, int & cons, char ch){
if (ch == 'a'||ch == 'e'||ch == 'i'||ch == 'o'||ch == 'u'||ch == 'A'||ch == 'E'||ch == 'I'||ch == 'O'||ch == 'U'){
vowel++;
}else if(ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' ){
cons++;
}
}