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 use of for loop?
i wanted to know about questions about c,c++ , which is required for placements.... im a fresher
method overloading means what?
what is the difference between thread and process
Name the different types of stl containers.
Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris");
What is the name of your birth place?
Define the terms: field, record, table and database
What are the components of stl?
how to swap two numbers in a linked list without exchanging the data but only the links?
What are the symptoms of stl?
Is string part of stl?