Structured Programming in C++
Prof. Gregory Safko
Camden County College, Cherry Hill Campus
Assigned: March 26, 2004
Due: April 2, 2004
Write a function countVowels that counts the number of vowels in a word (a string)
The function will accept one string parameter, and will return the number of vowels it finds
The function prototype (above main) should look like this:
int countVowels(string s);
Also write a suitable main program to demonstrate your function. Test it with the following strings:
String: Return value
College 3
Happy 1 (in this program, the letter y is not a vowel)
rhythm 0
Write a function countNonAlphas that counts the number of non-alphabetic characters in a word (a string). A non-alpha character is any character that is not a letter of the alphabet
The function will accept one string parameter, and will return the number of non-alphabetic characters it finds
The function prototype (above main) should look like this:
int countNonAlphas(string s);
Also write a suitable main program to demonstrate your function. Test it with the following strings:
String: Return value
R2D2 2
Life-boat 1
hello 0
99-66 5
Write a function countNonAlphanumerics that counts the number of non-alphanumeric characters in a word (a string). A non-alphanumeric character is any character that is not a letter of the alphabet or a number
The function will accept one string parameter, and will return the number of non-alphanumeric characters it finds
The function prototype (above main) should look like this:
int countNonAlphanumerics(string s);
Also write a suitable main program to demonstrate your function. Test it with the following strings:
String: Return value
R2D2 0
Life-boat 1
hello 0
99-66 1
A_B_C 2