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
In what scenario does the Logical file and Physical file being used?
How stl is different from the c++ standard library?
Is stl open source?
Is there any error below, its a code to delete all entires from a map #include
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
How is stl different from c++ standard library?
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
What is a list in c++ stl?
Can we use stl in coding interviews?
How connect plc and pc through software
What do stl stand for?
What are the components of stl?
Describe the My Computer and My Documents folders; identify the elements that are present in every Window.
Define stl.