Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. //TASK 6
  4.  
  5. int main ( void )
  6. {
  7. int charcount = 0;
  8. int wordcount = 0;
  9. int linecount = 0;
  10. int c;
  11.  
  12. while ((c=getchar()) != EOF) {
  13.  
  14. if ((c != ' ') && (c != '\n')) {
  15. //Adding to character count
  16. charcount++;
  17. }
  18.  
  19. if ((c == ' ') || (c == '\n')) {
  20. //Adding to word count
  21. wordcount++;
  22. }
  23.  
  24. if (c == '\n') {
  25. //Adding to line count
  26. linecount++;
  27. }
  28. }
  29.  
  30. printf("%lu %lu %lu\n", charcount, wordcount, linecount);
  31. return 0;
  32.  
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement