Example 1 : Calculates the number of vowels in a string #include #include using namespace std; int main() { int a,b; char word[100]; cout << "Enter a word \n"; cin >> word; a=0; b=0; while (word[a] != '\0') { switch (word[a]) { case 'a': case 'A': b++; break; case 'e': case 'E': b++; break; case 'i': case 'I': b++; break; case 'o': case 'O': b++; break; case 'u': case 'U': b++; break; } a++; } cout << "Number of vowels in the word \"" << word << "\" is " << b << "\n"; cout << "Number of characters in it is " << a << "\n"; cout << "Check if the above number is the same as "<< strlen(word) << "\n"; return 0; } Example 2: Does the same thing as (1) but does not use "switch". When there is a large number of conditions to be checked (like in this example) the switch statement is preferable. So (in my opinion) this is a bad program. #include #include using namespace std; int main() { int a,b=0; char word[100]; cout << "Enter a word \n"; cin >> word; for(a=0; a