View Code of Problem 58

#include<stdio.h>
int main()
{ 
  char str[100];
  gets(str);
 int i=0,count=0,flag;
 
   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