Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- int count = 0; // // counter for counting
- int letter, ok = 0; // ok is a indicator var
- printf("Write the text.\n");
- while( (letter = getchar()) != EOF ) // whilte untill EOF - CTRLZ .
- {
- switch(letter)
- {
- case 'y': case 'Y': // Checks the letter for y or Y with capslock
- ok = 1;
- continue;
- case 'e': case 'E': // Checks the letter for e or E with capslock
- if(ok++ == 1) continue;
- break;
- case 's': case 'S': // Checks the letter for s or S with capslock
- if(ok == 2) ++count;
- break;
- }
- ok = 0;
- }
- printf("The word yes has appeared %d times in the text.\n", count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment