#include #include #include #include // provides isalnum() using namespace std; // function object class used in call to count_if class AlphaFinder { public: bool operator() (char c) { return isalnum(c); } }; void main() { const int NO_LETTERS = 26; string s; cout << "Please enter a string of characters:" << endl ; getline(cin,s); for (int i = 0; i < NO_LETTERS; i++) { cout << "# of " << static_cast('a'+i) << "'s:" << count(s.begin(), s.end(), 'a'+i) << "\t"; } cout << endl << "No of alphanumeric characters: " << count_if(s.begin(), s.end(), AlphaFinder()) << endl; }