Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++program that prompts the user with the following menu options: Erase-ArrayContent count-words Rev-Words Quit For Erase-ArrayContent option, write complete code for the C++function
Write a C++program that prompts the user with the following menu options: Erase-ArrayContent count-words Rev-Words Quit For Erase-ArrayContent option, write complete code for the C++function Erase described below. The prototype for Erase is as follows: void Erase(int al N, int Search-Element) The function Erase should remove all occurrences of Search-Element from the array al. Note that array al 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 returming from the function. It is also assumed that al0 through aIN-1 contain valid items upon entering and al0] through alN-11 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 Count-Words option, write a C++ program that moves linearly through char data in an array b until a in' is reached. The program should count the total number of words in a sentence typed in by the user from 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 n character. For example, if the array bl contains: the Dog At5674 654 Mypaper n', your program should output: Total word count: 3. Words are: Dog, At5674, Mypaper 3. For the Rev-words option, create a C++ function. RevwordslnPlace, 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 (n) 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
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