Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started