C Program to Count Occurrence of Words in Sentence.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 clrscr();
 char strs[100], countw=0, strw[15], i;
 printf("Write a sentence : ");
 gets(strs);
 int len=strlen(strs);
 for(i=0; i<len; i++)
 {
  if(strs[i]==' ')
  {
   countw++;
  }
 }
 printf("Total number of words in the sentence is %d",countw+1);
 getch();
}
C Program to Count Occurrence of Words in Sentence. C Program to Count Occurrence of Words in Sentence. Reviewed by on December 26, 2019 Rating: 5

No comments:

Powered by Blogger.