DESCRIPTION: This program checks for the number of words present in the text using the spaces in the text to distinguish words.
PROGRAM:
#include<stdio.h>
main()
{
char a[50],i,count=1;
printf("Enter the string\n");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' '&&a[i+1]!=' ')
count++;
}
printf("Number of words =%d",count);
}
OUTPUT WINDOW: