Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main() {
  4. char str[30];
  5. int i = 0;
  6. int cc = 0;
  7. int ac = 0;
  8. int wc = 1;
  9. int ssc = 0;
  10. int dc = 0;
  11. int nl = 1;
  12. printf("print a paragraph at the end press #:");
  13. scanf(" %[^#]",str);
  14. while (str[i] != '\0') {
  15. if (str[i] >= 65 && str[i] <= 91 || str[i] >= 97 && str[i] <= 123) {
  16. ac++;
  17. cc++;
  18. }
  19. else if (str[i] >= 40 && str[i] <= 49) {
  20. dc++;
  21. cc++;
  22. }
  23. else if (str[i] == ' ') {
  24. wc++;
  25. cc++;
  26. }
  27. else if (str[i] == '\n') {
  28. nl++;
  29. cc++;
  30. wc++;
  31. }
  32. else {
  33. ssc++;
  34. cc++;
  35. }
  36. i++;
  37. }
  38. printf(" i = %d\n wc = %d\n ssc = %d\n dc = %d\n ac = %d\n cc = %d\n nl = %d\n",i ,wc ,ssc ,dc ,ac ,cc ,nl);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement