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



5. Write c++ function that would intake a string and return the number of occurrences of a given ch..

Answer / 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

More STL Interview Questions

Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.

0 Answers  


What is stl language?

0 Answers  


What is the stl, standard template library?

0 Answers  


WHAT IS THE DIFFERENCE BETWEEN C++ AND VC++

1 Answers   Syntel,


What do stl stand for?

0 Answers  






Who wrote stl?

0 Answers  


what is a template?

2 Answers   Amazon, BITS, IBS, Wipro,


how to swap two numbers in a linked list without exchanging the data but only the links?

3 Answers   Wipro,


what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?

2 Answers  


wap in c++ which accept a integer array and its size as argument and replaces element having even values with its half and element having odd values with twice its value

1 Answers  


What is Object Oriental Progam

2 Answers  


totoo po ba ang manga aliens!

0 Answers  


Categories