Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Which of the following IP addresses cannot be host addresses

Answered: 1 week ago

Question

Find magnitude of vector difference A - B

Answered: 1 week ago