Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A regular dictionary contains the words and the definitions. In addition to the words and the definitions, we will also store the part-of-speech (pos). The

A regular dictionary contains the words and the definitions. In addition to the words and the definitions, we will also store the part-of-speech (pos). The words, definitions and pos are going to be stored in Arrays. Use these global-variables in your code outside main() function:

const int g_MAX_WORDS = 1000; int g_word_count = 0; string g_words[g_MAX_WORDS]; string g_definitions[g_MAX_WORDS]; string g_pos[g_MAX_WORDS]; 

Create a C++ file and add the following function:

/* @param : The string with the `filename` @post : Reads the words, definitions pos into the global-arrays and set the value of `g_word_count` to the number of words read */ void readWords(string filename); 

Heres an example text file:

WORD POS : DEFINITION Grumpy Adjective : bad-tempered and irritable Professor Noun : a teacher of the highest rank in a college or university Does Verb : perform (an action, often of unspecified nature) Nothing Adverb : not at all 

Example:

Calling readWords() on the above text file will modify the global variables like this:

g_MAX_WORDS: 1000 g_word_count: 5 g_words: ["WORD", "Grumpy", "Professor", "Does", "Nothing"] g_pos: ["POS", "Adjective", "Noun", "Verb", "Adverb"] g_definitions: [ "DEFINITION", "bad-tempered and irritable", "a teacher of the highest rank in a college or university", "perform (an action, often of unspecified nature)", "not at all" ] 

Make sure your program produces the correct output by testing the function and global-variables using main() function.

Note: Only submit single .cpp file to gradescope. Remove or comment out the main function from your code before submitting it on gradescope. Otherwise, the autograder will fail.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

Students also viewed these Databases questions