//////////////////////////////////////////////////////// // // vowel.cpp // // Started 1/5/97 by Jeff Ondich // Last modified: 1/5/97 // // This program illustrates the use of functions in // C++ programs. // //////////////////////////////////////////////////////// #include int VowelCount( char *str ); int main( void ) { char theString[100]; cout << "Type something, please: "; cin >> theString; cout << '\"' << theString << '\"' << " contains " << VowelCount( theString ) << " vowels." << endl; return( 0 ); } //////////////////////////////////////////////////////// // // Returns the number of vowels contained in the // given null-terminated character string. Y's // are not considered vowels for this function. // //////////////////////////////////////////////////////// int VowelCount( char *str ) { int count = 0; for( int i=0; str[i] != '\0'; i++ ) { if( str[i] == 'a' || str[i] == 'A' || str[i] == 'e' || str[i] == 'E' || str[i] == 'i' || str[i] == 'I' || str[i] == 'o' || str[i] == 'O' || str[i] == 'u' || str[i] == 'U' ) { count = count + 1; } } return( count ); }