You can break this problem down by working from the outside in: start from the inputs and work forward. Then start with the outputs and work back. Pretty soon you'll have a design.
Okay, starting with the input, you need code that will break a line into individual words.
Starting from the output, it's clear that you'll need two functions: one takes a word and returns the number of vowels in it. The other takes a word and returns the number of consonants. Or you could do one function that does both: void classifyWord(const std::string &word, int &vowels, int &consonants);
To find the anwers, you'll need to track the word with the most vowels, along with it's count. Also the word with the fewest vowels and its count:
Now it should be clear how to put the pieces together:
1 2 3 4 5 6 7 8 9 10
read the string.
for each word in the string {
count the vowels and consonants
if the vowels > vowelWord.count {
vowelWord.word = this word;
vowelWord.count = this word's vowels
}
and the same logic for consonants.
}
print the results.
This is very much like the min/max problem, where you find the smallest/largest integer in an array.
Step 1: Get the array of words from the user. (If you know how to use a std::vector, use it instead of a C-style array.)
Step 2: Write a function that determines the number of vowels in a word. It should look (prototype) something like this:
int count_vowels( string s );
Step 3: Just like finding the maximum integer value in an array (or vector) of integer values, you must now find the string with the maximum number of vowels in the array (or vector) of strings. Remember that you'll need two additional variables (current string with max vowels, number of vowels in current string with max values) before iterating through the array/vector.
Step 4: Do the same thing, except counting consonants. There is an easy mathematical trick to get the number of consonants in a word if you know the number of vowels.