Question: C++ Lab 1b 2. Create a program named lab1b_2.cpp which contains a function that returns the number of times that the string hi appears anywhere

C++

Lab 1b 2. Create a program named lab1b_2.cpp which contains a function that returns the number of times that the string "hi" appears anywhere in a given string. For example, if "abc hi ho" was passed in, it would return a 1. If "ABChi hi" was passed in, it would return a 2. If "hihi" was passed into the funciton, it would return a 2. Heres the prototype: int countHi(string str); Create a driver (a main file) which asks the user for a string, and then print the number of times "hi" appears in that string. Example: Enter a string: how is everyone? hi appears 0 times. Example: Enter a string: The hint is to be nice and say hi. hi appears 2 times

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!