Question: Write a C++ program which will prompt the user to enter some words and then sort the words in alphabetical order and display them. There

Write a C++ program which will prompt the user to enter some words and then sort the words in
alphabetical order and display them. There is an extra credit option for this assignment.
Requirements:
Store the words entered by the user in an array of strings (each element of the array is of type string).
The maximum number of words for which the program needs to work must be set using the following constant (a global constant at the top of the program):
const int NUM_WORDS = 10;
Then, throughout the program wherever this size is needed, the constant must be used rather than a literal number.
You can assume that each word entered by the user will not contain any spaces, so the words can be read in using cin >>.
The program must stop prompting for further input if the maximum number of words is reached, or if the user enters 0 as one of the words. If the user enters 0 to end the input sequence, then the 0 must not be counted as one of the words sorted and later displayed.
SortingofthewordsmustbedoneusingtheBubbleSortmethod,implementedinafunction with this prototype:
void bubbleSort(string words[], int num);
This function must sort the first num strings of the words array from smallest to largest as determined by either the compare function (for any strings, whether of letters or not), or using the < operator
Dont do anything special to account for upper- or lower-case letters all upper-case letters will be considered as coming before all lower-case letters (this is known as lexicographic sorting).
For Extra Credit, see the extra credit section
A sample run of your program should look like:
Enter a word: dog
Enter a word: Dogs
Enter a word: beaver
Enter a word: Cat
Enter a word: Mouse
Enter a word: rabbit
Enter a word: 0
Your sorted list is: Cat Dogs Mouse beaver dog rabbit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!