View Code of Problem 58

#include<stdio.h>
int main()
{ 
  char str[100];
  gets(str);
 int flag, i=0,count=0;
   while(str[i]!='\0')
  {
    if(str[i]==' ')
        flag=0;
      
  else if(flag==0)
	  {
	  count++;
      flag=1;
	  }
     
	  i++;
  
  }
 printf("%d\n",count);
 return 0;
}

Double click to view unformatted code.


Back to problem 58