1. Engineering
  2. Computer Science
  3. c lab 1b 2 create a program named lab1b2cpp which...

Question: c lab 1b 2 create a program named lab1b2cpp which...

Question details

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. Here’s 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

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution