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
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.
How is stl different from c++ standard library?
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
Is there any error below, its a code to delete all entires from a map #include
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
What is stl in oop?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
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
What is the stl, standard template library?
Is string part of stl?
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command
What are the different types of stl containers?
what is template and type convertion
Define stl.
Explain stl.