0 switch ch case a result0 break case e result1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ount_vowels(int *, char *); Name: Lab Section: int main() { count_vowels(counter, message); // after the call, counter == {0, 3, 0, 2, 0, 0} } // YOUR TESTING CODE // Count the number of vowel letters in a string. // “str” is the pointer to the input string. // Return the number of vowel letters in the array // referenced by “result". The value of array elements // may not necessarily be zero in the beginning. int count_vowels(int result, char *str) { // YOUR CODE } Test your code, and the cut and paste your whole program here. int count_vowels(int result, char *str) { char ch; // clear result for (int i = 0; i < 5; i++) result[i] = 0; // scan the string for vowels while ((ch = *str++) != ‘\0’) { switch (ch) { case ‘a’: result[0]++; break; case ‘e’: result[1]++; break; case ‘i’: result[2]++; break; case ‘o’: result[3]++; break; case ‘u’: result[4]++; Name: Lab Section: break; } } Question 3: For, Whi...
View Full Document

This note was uploaded on 02/24/2013 for the course CPR E 288 taught by Professor Staff during the Fall '08 term at Iowa State.

Ask a homework question - tutors are online