Nayeemzaman

cw

Nov 9th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,l,word=0,space=0,a=0;
  5.     char ch[1000];
  6.     gets(ch);
  7.     l=strlen(ch);
  8.     for(i=0; i<l; i++)
  9.     {
  10.         if(ch[i]!=' '&&ch[i]!='\t')
  11.         {
  12.             word++;
  13.             while(ch[i]!=' '&&ch[i]!='\t')
  14.             {
  15.                 int ct=0;
  16.                 i++;
  17.                 if(ch[i]>='a'&&ch[i]<='z'||ch[i]>='A'&&ch[i]<='Z')
  18.                 {ct++;}
  19.                 if(ct==0){a=a+1;}
  20.             }
  21.         }
  22.         space++;
  23.     }
  24.     printf("a = %d\n",a);
  25.         printf("Word = %d\n",word-a);
  26.     if(ch[l-1]==' ')
  27.         printf("Space = %d\n",space);
  28.     else
  29.         printf("Space = %d\n",space-1);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment