Kat H.

asked • 04/27/21

Count E's. Read in a string, print out the number of e's in it.

Read in a string, print out the number of e's in it. Note that the string may have spaces in it. A call to getline looks like getline(cin, myVariable) where myVariable is a string variable that will be set to hold the contents of the line.


Samples:

Input: Jane Doe Output: 2
Input: why Output: 0


Hints:

  1. there is no magic "count things" function
  2. A good first step would be to print out all the characters one at a time. Then maybe modify your code to only print when you see an 'e'. Then worry about counting them.

Code:


#include <iostream>

using namespace std;


int main()

{

//YOUR_CODE

}

1 Expert Answer

By:

Patrick B. answered • 04/27/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.