Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. char string[100];
  7. int c=0,count[25]={};
  8.  
  9. cout<<"Enter a string\n";
  10. cin.get(string,100);
  11. while( string[c] != '\0' )
  12. {
  13. if( string[c] >= 'a' && string[c] <= 'z' )
  14. count[string[c]-'a']++;
  15. c++;
  16. }
  17. for(c=0;c<26;c++)
  18. {
  19. if(count[c])
  20. cout<< (char) (c+'a')<<" occurs "<< count[c] << " times in the entered string.\n";
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement