Question: Write a function called count_words which counts how many strings end with ed in an array. The function has two parameters, an array and its

 Write a function called count_words which counts how many strings end

Write a function called count_words which counts how many strings end with "ed" in an array. The function has two parameters, an array and its size. The function returns an integer, i.e. the number of strings that end with "ed". The function must not modify the input array and so the input parameter must be indicated as such. Assume that all the strings in the array will be lower case. For example, if the input array is {"red", "", "a", "blue", "white", "liked", "exited", "mango", "black", "ed", "bob"} then the function will return 4. Write both the function header and your solution in the function body. You will NOT write an entire program here. Be sure to use pass by value and pass by reference where appropriate and the const specifier. Don't forget the return type. Assume that the iostream and string libraries have been included already and that we are using the std namespace. The string operations introduced in lecture are: length (), substr (index, n), replace(index, n, str), and insert(index, str)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!