Saturday, October 22, 2011

TO COUNT NUMBER OF WORDS IN A SENTENCE

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
int main ()
{char str1[100];
int i,x,c;
gets(str1);
c=0;
for(i=0;str1[i]!='\0';++i)
{
if(str1[i]==' ')
++c;
}


x=c+1;



printf("no of word is %d",x);
getch();
return 0;
}

1 comment: