Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. char str[50];
  7. int i = 0,
  8. count[26] = { 0 },
  9. b;
  10.  
  11. printf("Enter string: ");
  12. scanf("%s", str);
  13.  
  14. while (str[i] != '\0')
  15. {
  16. if (str[i] >= 'a' && str[i] <= 'z')
  17. {
  18. b = str[i] - 'a';
  19. count[b]++;
  20. }
  21. ++i;
  22. }
  23.  
  24. for (i = 0; i < 26; ++i)
  25. {
  26. printf("%c-%d\n", i + 'a', count[i]);
  27. }
  28. getchar(); getchar();
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement