#include int countword(char []); // function prototype int main() { const int MAXNUM = 1000; char message[MAXNUM]; int numword; cout << "\nType in any number of words: "; cin.getline(message,MAXNUM); numword = countword(message); cout << "The number of words just entered is " << numword << endl; return 0; } int countword(char list[]) { const int YES = 1; const int NO = 0; int i, inaword, count = 0; inaword = NO; for(i = 0; list[i] != '\0'; i++) { if (list[i] == ' ') inaword = NO; else if (inaword == NO) { inaword = YES; count++; } } return count; }