Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int i,l,word=0,space=0,a=0;
- char ch[1000];
- gets(ch);
- l=strlen(ch);
- for(i=0; i<l; i++)
- {
- if(ch[i]!=' '&&ch[i]!='\t')
- {
- word++;
- while(ch[i]!=' '&&ch[i]!='\t')
- {
- int ct=0;
- i++;
- if(ch[i]>='a'&&ch[i]<='z'||ch[i]>='A'&&ch[i]<='Z')
- {ct++;}
- if(ct==0){a=a+1;}
- }
- }
- space++;
- }
- printf("a = %d\n",a);
- printf("Word = %d\n",word-a);
- if(ch[l-1]==' ')
- printf("Space = %d\n",space);
- else
- printf("Space = %d\n",space-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment