Question
Write a C++ program that prompts the user with the following menu options: E raseArrayContent Count W ords R evWords Q uit For EraseArrayContent option,
Write a C++ program that prompts the user with the following menu options:
EraseArrayContent CountWords RevWords Quit
For EraseArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase is as follows:
void Erase( int a[ ], int * N, int * Search-Element )
The function Erase should remove all occurrences of Search-Element from the array a[ ]. Note that array a[ ] is loaded with integer numbers entered by the user through the keyboard. N is the number of items in the array upon entrance to the function and N should be the number of items remaining in the array upon returning from the function. It is also assumed that a[0] through a[N-1] contain valid items upon entering and a[0] through a[N-1] should still contain the same items upon returning from the function, except all occurrences of Search-Element have been removed. (e.g. You should not leave 'gaps' in the array when you remove Search-Element. For example Delete 6 from the array 3,4,6,2,1,6,8 with N=7. You could end up with, for example, the array 3, 4, 2, 1, 8, and N=5.
For the CountWords option, write a C++ program that moves linearly through char data in an array b[ ] until a ' ' is reached. The program should count the total number of words in a sentence typed in by the userfrom keyboard and should output the result. A word is defined to be any contiguous group of ASCII chars that start with letters A through Z (upper case ) that don't contain white space. Words are separated by white space - e.g. blanks, or tabs. Of course, the last word could be terminated by the ' ' character. For example, if the array b[] contains: the Dog At5674 654 Mypaper' ', your program should output: Total word count: 3. Words are: Dog, At5674, Mypaper.
For the RevWords option, create a C++ function, RevWordsInPlace, which has the prototype
void RevWordsInPlace(char array[]);
The function should reverse the words contained in array. The words in array are separated one from another by a space (' ') character, the first character of the first word is in array[0], and a newline (' ') character immediately follows the last character of the last word. The reversal must be done in-place, that is, no local (temporary) arrays should be used. You may use appropriate local variables for counting and indexing purposes.
Examples
Array Before Array After
{one-word} {one-word}
{testing one two three} {three two one testing}
{Sam and Kate are happy} {happy are Kate and Sam}
If the user enters Q or q then you should verify that the user wants to terminate the program before actually terminating the program. If the user enters any other selection it should prompts the user invalid selection and tries again.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started