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
Can we use stl in coding interviews?
Name the different types of stl containers.
Is there any error below, its a code to delete all entires from a map #include
a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.
What are stl algorithms?
What is stl in oop?
sir please send me bpcl previous question papers
Describe the My Computer and My Documents folders; identify the elements that are present in every Window.
how to use C++?
Who created stl?
please visit this site you'll find my question this is my homework please answer it if you can http://easyscience.org/ib/lofiversion/index.php/t36168.html
how can u do connectivity in c++ language? plz send me connectivity code in c++ ?
How does an stl file work?
write a program to convert a decimal number in to its equivalent binary number?
What is a list in c++ stl?