#include #include #include using namespace std; int main() { int count[26]; // make sure to initialize all entries for (int i=0; i<=26; i++) count[i] = 0; // read the data from the user until invalid entry reached string word; cout << "Please enter full text." << endl; cout << "End of data should be signified with cntr-D" << endl; while (cin >> word) { char leading = word.at(0); if (leading >= 'a' && leading <= 'z') count[leading-'a']++; else if (leading >= 'A' && leading <= 'Z') count[leading-'A']++; } // generate the histogram for (int i=0; i<26; i++) { char c = (i+'a'); cout << c << " : " << setw(5) << count[i] << endl; } }