Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a C++ program that prompts the user with the following menu options: EraseArray Content CountWords RevWords Quit 1) For EraseArrayContent option, write complete code

Write a C++ program that prompts the user with the following menu options:

EraseArray Content CountWords RevWords Quit

1) 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.

2) 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.

3) 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.

4) 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 prompt the user invalid selection and tries again.

**Note: Each part should be handled by a separate function. You must use pointer notations for all three parts. Do not use any global arrays, variables, or subscript notation.

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_2

Step: 3

blur-text-image_step3

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

More Books

Students explore these related Databases questions

Question

What is an agent-based computational model?

Answered: 3 weeks ago

Question

What is the process of normalization?

Answered: 3 weeks ago