5. Write c++ function that would intake a string and return
the number of occurrences of a given character in that sring
Ex:- if the word is “Colombo” and count the occurrences of
the letter “o” the function would return 3
Answer Posted / qliubrvq
occurrences(string str, char test) {
int len = str.size();
int count = 0;
for (int i = 0; i < len; i++) {
if (str[i] == test) count++;
}
return count;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is template and type convertion
What are the symptoms of stl?
What is a standard template library (stl)? What are the various types of stl containers?
Who created stl?
What is stl stack?
Why should a c++ programmer be interested in stl?
help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase
Do you like to Submit Questions in Bulk under Same Category?? Then use our Bulk ListerDo you like to Submit Questions in Bulk under Same Category?? Then use our Bulk Lister
How connect plc and pc through software
What is the stl, standard template library?
What is meant by stl in c++?
How stl is different from the c++ standard library?
Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.
Is there any error below, its a code to delete all entires from a map #include
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.