Write a program that reads 10,000 words into an array of strings; the "List of 10,000 Random Words" file is on Moodle. The program will then read a second file (the list of "Search Words" is also on Moodle) that contains an undetermined number of words and search the first array for each word. The program will then report the number of words in the second list that were found on the first list. Do not use an array for the second file, process the words as they are read. Note that some of these "words" might have spaces; handle your input accordingly. THIS IS AN ALL OR NOTHING QUIZ I ONLY HAVE TWO ATTEMPTS LEFT PLEASE HELP. THE ANSWER IS NOT 347!! I will insert the text files as a google drive link for you to view: list of 10,000 random words - https://drive.google.com/file/d/1WSrOEBnrwaUh3HYxvz9cto0SVKVqe4MI/view?usp=sharing search words - https://drive.google.com/file/d/1qtAlDV5ec_3g8S7NLYf3DlTXrQLE24ME/view?usp=sharing       Here is the code : #include #include #include using namespace std; const int NUM_WORDS = 10000; // number of words in the first array int main() { // declare and initialize the first array with the 10,000 words string words[NUM_WORDS]; ifstream infile("1000RandomWords.txt"); for (int i = 0; i < NUM_WORDS; i++) { infile >> words[i]; } infile.close(); // open the second file and read the words one by one ifstream searchfile("Search Words.txt"); string searchword; int count = 0; // counter for the number of words found while (searchfile >> searchword) { // search the first array for the current search word for (int i = 0; i < NUM_WORDS; i++) { if (words[i] == searchword) { // if the search word is found, increment the counter count++; break; // exit the loop } } } searchfile.close(); // print the number of words found cout << "Number of words found: " << count << endl; return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a program that reads 10,000 words into an array of strings; the "List of 10,000 Random Words" file is on Moodle. The program will then read a second file (the list of "Search Words" is also on Moodle) that contains an undetermined number of words and search the first array for each word. The program will then report the number of words in the second list that were found on the first list. Do not use an array for the second file, process the words as they are read. Note that some of these "words" might have spaces; handle your input accordingly.

THIS IS AN ALL OR NOTHING QUIZ I ONLY HAVE TWO ATTEMPTS LEFT PLEASE HELP. THE ANSWER IS NOT 347!!

I will insert the text files as a google drive link for you to view:

list of 10,000 random words - https://drive.google.com/file/d/1WSrOEBnrwaUh3HYxvz9cto0SVKVqe4MI/view?usp=sharing

search words - https://drive.google.com/file/d/1qtAlDV5ec_3g8S7NLYf3DlTXrQLE24ME/view?usp=sharing

 

 

 

Here is the code :

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int NUM_WORDS = 10000; // number of words in the first array

int main() {
// declare and initialize the first array with the 10,000 words
string words[NUM_WORDS];
ifstream infile("1000RandomWords.txt");
for (int i = 0; i < NUM_WORDS; i++) {
infile >> words[i];
}
infile.close();

// open the second file and read the words one by one
ifstream searchfile("Search Words.txt");
string searchword;
int count = 0; // counter for the number of words found
while (searchfile >> searchword) {
// search the first array for the current search word
for (int i = 0; i < NUM_WORDS; i++) {
if (words[i] == searchword) {
// if the search word is found, increment the counter
count++;
break; // exit the loop
}
}
}
searchfile.close();

// print the number of words found
cout << "Number of words found: " << count << endl;

return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education