Name your source code as cpp replace the text with with your
Solution
// C++ code
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <vector>
using namespace std;
int main()
{
std::vector<string> words;
string word;
while(true)
{
cout << \"Enter word: \";
cin >> word;
if(word == \"end\")
break;
else
words.push_back(word);
}
string search;
cout << \"Enter a word to search: \";
cin >> search;
int count = 0;
for (int i = 0; i < words.size(); ++i)
{
if(words[i] == search)
count++;
}
cout << search << \" occured \" << count << \" times in the list of words\ \";
}
/*
output:
Enter word: my
Enter word: name
Enter word: is
Enter word: ayush
Enter word: verma
Enter word: I
Enter word: ayush
Enter word: go
Enter word: to
Enter word: school
Enter word: my
Enter word: my
Enter word: my
Enter word: native
Enter word: end
Enter a word to search: my
my occured 4 times in the list of words
*/

