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

What is a stl vector?

0 Answers  


How to write a function that goes through an array of characters and eliminates any elements that are not letters (Legal letters can be either in an uppercase or a lowercase format.) The function removeNonLetters should return the new effective size of the array as the result.

2 Answers  


what is an algorithm in terms of STL?

1 Answers   Lucent, Wipro,


How do I convert a stl file?

0 Answers  


How stl is different from the c++ standard library?

0 Answers  


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

6 Answers  


#define CUBE(x) (x*x*x) main() { int a,b=3; a=cube(b++); printf("%d %d",a,b); } What should be the value of a and b? My calc a=4 but syst a=6 how pls tell me if you know it?

12 Answers   Wipro,


sir please send me bpcl previous question papers

0 Answers   BPCL Bharat Petroleum,


what is compiler?

4 Answers   NASA,


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.

0 Answers  


How does an stl file work?

0 Answers  


what is use of for loop?

9 Answers   Wipro,


Categories