Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

draw a flowchart that accepts two numbers and checks if the first is divisible by the second.

0 Answers   Appin, NIIT,


How do I convert a stl file?

0 Answers  


What is the STL?

2 Answers   Epson, HP,


Write a program in C/C++ to implement reader- writer problem

1 Answers   Wipro,


how to overload << and >> operator in c++

3 Answers   Wipro,


write a c++ to define a class box with length,breadth and height as data member and input value(),printvalue() and volume() as member functions.

3 Answers  


what's the difference between function overloading and function overiding?

5 Answers  


why does the execution of a c++ program start with main()???

11 Answers  


What two types of containers does the stl provide?

0 Answers  


if 4-5 year old brother is standing on d roof with me and watching d moon, suddenly moon coverd by cloud then how will i explain d hiding of moon to my brother.

8 Answers   MBT,


Explain when u will use Observer pattern and how u will implement in c++ .

1 Answers  


what is compiler?

4 Answers   NASA,


Categories