Implement a function, countVowels, which takes in a string and counts the number of vowels that are contained within it. Make sure that both capital vowels and lowercase vowels are counted. Your starter code contains a main function, which asks for user input and outputs the number of vowels. You will need to implement the user input for the string. Sample Runs (user input is italicized and underlined):
Implement a function, countVowels, which takes in a string and counts the number of vowels that are contained within it. Make sure that both capital vowels and lowercase vowels are counted.
Your starter code contains a main function, which asks for user input and outputs the number of vowels. You will need to implement the user input for the string.
Sample Runs (user input is italicized and underlined):
Enter a phrase: Hello World!
Number of vowels: 3
Enter a phrase: PROGRAMMING IS EXCELLENT.
Number of vowels: 7
#include <string>
#include <iostream>
using namespace std;
int countVowels(string word);
int main()
{
string phrase;
cout << "Enter a phrase: ";
// To do: implement user input
cout << "Number of vowels: " << countVowels(phrase) << endl;
}
// To do: Implement countVowels
int countVowels(string word)
{
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images