Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define LEN 15
  4.  
  5. int main(void)
  6. {
  7. char string[LEN+1], ch;
  8.  
  9.  
  10. printf("Enter a word>\n");
  11. scanf("%s", string);
  12.  
  13. for (ch = 'a'; ch <= 'z'; ch++)
  14. {
  15. int count = 0, i;
  16. for (i = 0; i < strlen(string); i++)
  17. {
  18. if (ch == string[i])
  19. {
  20. count++;
  21. }
  22. }
  23.  
  24. if (count > 1)
  25. {
  26. printf("Duplicate letter: %c, Occurrences: %d\n", ch, count);
  27. }
  28. else
  29. {
  30. printf("No duplicates found\n");
  31. }
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement