#include #include using namespace std; // count words in the standard input stream, cin int main() { const string LAST_WORD = "end"; string word; int numWords = 0; // initially, no words cout << "type '" << LAST_WORD << "' to terminate input" << endl; cin >> word; while (word != LAST_WORD) // read succeeded { numWords++; cin >> word; } cout << "number of words read = " << numWords << endl; return 0; }