Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. define N 7
  3. main()
  4. {
  5. char str[N+1]= {0};
  6. printf("Enter alphabets: ");
  7.  
  8. gets(str);
  9.  
  10. printf("Alphabets are %s\n", str);
  11.  
  12. char ch;
  13. int i=0;
  14. int count[26]={0};
  15.  
  16. while( (ch=str[i]) != '\0')
  17. {
  18. count[ch-'a']++;
  19. i++;
  20. }
  21.  
  22. for(i=0;i<26;i++)
  23. {
  24. if(count[i])
  25. {
  26. printf("%c %d\n",i+'a',count[i]);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement