Program to Calculate Number Of Words In a Text:
#include<iostream>
#include<string.h>
using namespace std;
main()
{
char string[100];
int l,ans=1;
cout<<"Enter Text\n";
cin.getline(string,100);
l=strlen(string);
cout<<"Total No of Words ";
for(int i=0;i<l;i++)
{
if(string[i]==' ')
{
ans++;
}
}
cout<<ans;
}
Special Thanks To Mr.Nikhil Aggarwal for this idea