Question: In C++ Define a function int countVowels(char s[]) that returns the number of times a vowel (a, e, i, o, u, 'A', 'E', 'I', 'O',

In C++

Define a function int countVowels(char s[]) that returns the number of times a vowel (a, e, i, o, u, 'A', 'E', 'I', 'O', 'U') occurs in s.

Since determining whether 'y' is a vowel can be difficult, we won't count 'y' or 'Y' as a vowel. For example: countVowels("feeder") will return 3. countVowels("facecious") will return 5. countVowels("dry") will return 0 (For our function, 'y' is not counted.) countVowels("AEIOUX") will return 5. (Uppercase vowels are counted.)

Below is the driver used to test your function.

#include

using namespace std;

int countVowels(char s[]);

int main() {

char s[60];

cin >> s;

cout << "Test string is " << s << endl;

cout << countVowels(s) ;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!