fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. void main()
  4. {
  5. int count=0,i,len;
  6. char str[100];
  7. printf("enter the sentence");
  8. gets(str);
  9. len=strlen(str);
  10. for(i=0;i<=len;i++)
  11. {
  12. if(str[i]==' ')
  13. count++;
  14. }
  15. printf("the number of words are :\t%d",count+1);
  16. }
  17.  
Runtime error #stdin #stdout 0s 2160KB
stdin
i am a girl
stdout
enter the sentencethe number of words are :	4