Guest User

Untitled

a guest
Nov 10th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int count = 0; // // counter for counting
  6. int letter, ok = 0; // ok is a indicator var
  7.  
  8. printf("Write the text.\n");
  9.  
  10. while( (letter = getchar()) != EOF ) // whilte untill EOF - CTRLZ .
  11. {
  12. switch(letter)
  13. {
  14. case 'y': case 'Y': // Checks the letter for y or Y with capslock
  15. ok = 1;
  16. continue;
  17.  
  18. case 'e': case 'E': // Checks the letter for e or E with capslock
  19. if(ok++ == 1) continue;
  20. break;
  21.  
  22. case 's': case 'S': // Checks the letter for s or S with capslock
  23. if(ok == 2) ++count;
  24. break;
  25. }
  26.  
  27. ok = 0;
  28. }
  29.  
  30. printf("The word yes has appeared %d times in the text.\n", count);
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment