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 / 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 |
What is a stl vector?
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.
what is an algorithm in terms of STL?
How do I convert a stl file?
How stl is different from the c++ standard library?
what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?
#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?
sir please send me bpcl previous question papers
0 Answers BPCL Bharat Petroleum,
what is compiler?
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 does an stl file work?
what is use of for loop?