Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<string.h>
  4.  
  5. int main()
  6. {
  7.     int i=0,count=0,max=0,add=0;
  8.     char str[255];
  9.     printf("Enter your sentence,use'_'to separate between words: ");
  10.     gets(str);
  11.     int y=strlen(str);
  12.     while(i<y)
  13.     {
  14.     while(str[i]!='_')
  15.         {
  16.             count++;
  17.             i++;
  18.             if(i==y)
  19.             break;
  20.         }
  21.         if(count>max)
  22.             max=count;
  23.             count=0;
  24.             i++;
  25.      }
  26.     printf("The longest word is=%d\n",max);
  27.      i=0;
  28.      while(i<y)
  29.      {
  30.          if(str[i]='(')
  31.          {
  32.         while (str[i]!=')')
  33.          {
  34.              if(str[i]!='_'&&str[i+1]=='_'&&str[i+2]!='_'&&str[i+2]!=')')
  35.                 add++;
  36.           i++;
  37.                 if(i==y)
  38.                     break;
  39.          }}
  40.      }
  41.      printf("The number of words inside parenthese=%d",add);
  42.     return 0;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement