Through this program our aim is to see the implementation (how it works) of count array and its use.
In general, the solution of this problem can be achieved by a simple program as:
using namespace std;
char k; int i,c=0;
cout<<"Enter Character(a-z) : ";
for(i=0;i<s.size();i++) // size() return the size of the string
if(s[i]==k) /*here we check for each string element,if string element s[i] is
equalto character k then increase c by 1.*/
cout<<k<<" occurs "<<c<<" times"<<endl;
Enter Character(a-z) : l
l occurs 2 times
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.