#include <stdio.h>
#include <string.h>
int main()
{
   char s[100];
    printf("enter the string:\n");
    fgets(s,100,stdin);
    int totalwords=1;
    for(int i=0;s[i]!='\0';i++)
        {
          if(s[i]==' ')
          {
              totalwords++;
          }
        }
    printf("the total words in the string are: %d",totalwords);
	return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: