Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<string.h>
- int main()
- {
- int i=0,count=0,max=0,add=0;
- char str[255];
- printf("Enter your sentence,use'_'to separate between words: ");
- gets(str);
- int y=strlen(str);
- while(i<y)
- {
- while(str[i]!='_')
- {
- count++;
- i++;
- if(i==y)
- break;
- }
- if(count>max)
- max=count;
- count=0;
- i++;
- }
- printf("The longest word is=%d\n",max);
- i=0;
- while(i<y)
- {
- if(str[i]='(')
- {
- while (str[i]!=')')
- {
- if(str[i]!='_'&&str[i+1]=='_'&&str[i+2]!='_'&&str[i+2]!=')')
- add++;
- i++;
- if(i==y)
- break;
- }}
- }
- printf("The number of words inside parenthese=%d",add);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement