PROGRAM:
#include<iostream>
using namespace std;
int main()
{
char str[100];
int w=1;
cout<<"Please enter a String: ";
gets(str);
for (int i=0;str[i]!=' ';i++)
{
if(str[i]==' ')
w++;
}
cout<<"There are "<<w<<" words.";
return 0;
}
Professional way of Programming