
please wait
|
|
|
|
const int arraysize = N;
|
|
char word; // string word; maybe?
|
|
one that takes the word and checks for the vowel and returns the amount(e.g. If word is hello, return 2, if word is hmm, return 0) |
|
|
Part I: Pointer-based string processing(cont.) Write a interactive program that asks the user to input a list of words and test whether there is a word that doesn't contain vowels. 1. You need to define a function called countVowel that checks whether a given word has vowels(containing any of a, e, i, o, u), return the number of vowels in this word. E.g., if the input word is "hello", you function should return 2, but if the input word in "hmm", then it should return 0. 2. Use the function countVowel to build another function isNoVowelWordOnList. The function isNoVowelWordOnList takes two arguments, the first argument is an array of strings containing a list of words and the second one is the size of this list. This function will scan the entire list and return the index of the first word that doesn't contain any vowels. If no such word exists in the list, then it will return -1. E.g., if the input list is {"what", "why", "when"}, then your function should return 1, but if the input list is {"hi", "hey", "hello"}, then you should return -1. 3. In the main function, you need to create a array of strings of size N(constant that you choose, say 5) to store the list of words, then ask user to input N word, one word each time, store them in the list and then check this list with your isNoVowelWordOnList function. Output the appropriate result. |
|
|
main |
|
|
|
|
|
|
|
|
|
|
That's my attempt at checking vowels... |
char words[arraysize];
int countVowels(int c)
You need to define a function called countVowel that checks whether a given word has vowels... |
if (c == 'a', 'e', 'i', 'o', 'u')
c = isNoVowelWordOnList(c);
...return the number of vowels in this word. |
int isNoVowelWordOnList(int i)
The function isNoVowelWordOnList takes two arguments, the first argument is an array of strings containing a list of words and the second one is the size of this list. |
You still seem very confused on some of the basics. char words[arraysize]; char, as the the name suggests is a character. a character is the same thing as a letter. If you plan to store words that are longer than one letter, this will not work. |
char *aWord
by any chance was he? Or am I getting confused by the meaning of your "word" meaning my "letter"?char word
?