Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- char string[100];
- int c=0,count[25]={};
- cout<<"Enter a string\n";
- cin.get(string,100);
- while( string[c] != '\0' )
- {
- if( string[c] >= 'a' && string[c] <= 'z' )
- count[string[c]-'a']++;
- c++;
- }
- for(c=0;c<26;c++)
- {
- if(count[c])
- cout<< (char) (c+'a')<<" occurs "<< count[c] << " times in the entered string.\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement