I've got to do a program that counts vowels, the user gives their input and the program outputs the number vowels the input has, it assignment says it HAS to use recursion so I can't find a way not to use it.
There's no errors in the system but it doesn't do what I want it to.
Here's what I got so far, I ended up making the strings into chars, because the switch didn't work
Basically I keep getting 0 as the output, I know counter is set to 0, but once it hits a vowel it should add counter++? That's what I want it to do. But I'm having a hard time getting anything but 0.
void vowelCounter(char sentence, int counter)
{
switch (sentence)
case'a':
case'A':
case'e':
case'E':
case'i':
case'I':
case'o':
case'O':
counter++;
if (counter = 0)
{
vowelCounter;
}
else
{
vowelCounter;
cout << "The number of vowels is: " << counter << endl;
}
}
int main()
{
char input;
int c = 0;
cout << "This program counts all the vowels in a sentence." << endl;
cout << "Enter a sentence!" << endl;
cin >> input; //get data from user
vowelCounter(input, c); //Call function vowelCounter
cout << endl;
system("pause");
return 0;
}