Question: 4.3.5: Advanced while loop examples. Use cin to read strings from input until Finale is read. Count the number of times the first string is
4.3.5: Advanced while loop examples.
Use cin to read strings from input until "Finale" is read. Count the number of times the first string is read from input, including the first instance.
Ex: If the input is:
Yam Cucumber Fig Leek Yam Finale
then the output is:
Yam occurs 2 time(s).
Note: x == y returns true if string x is equal to string y.
#include
int main() { string expectedItem; string nextItem; int yamCount;
cout << expectedItem << " occurs " << yamCount << " time(s)." << endl;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
