Question: Define 2 functions dealing with vectors and define main. The main ( ) function is not provided, you must create your own in main.cpp .

Define 2 functions dealing with vectors and define main.
The main() function is not provided, you must create your own in main.cpp.
Define the following functions in funcs.cpp. The function prototypes are as follows:
void reverseDisplay(vector vec); int numOfChar(vector vec, char c);
All the functions must work for any size vector.
void reverseDisplay(vector vec);
This function takes a char vector.
This function prints out the vector in reverse order. Each element of the vector will follow the prior element. Meaning no spaces or new lines between print outs of the elements. After the final element is printed out, print out a new line.
int numOfChar(vector vec, char c);
This function takes a char vector and a char.
This function searches the vector for the char, and returns the total number of occurrences of the char. No cout should appear in this function.
int main()
The main function will accomplish 3 things:
Declare an empty vector of chars.
Take an integer from user input. This integer will represent the number of chars the user will enter, to be placed in the vector.
Using a for loop, takes n chars from cin and populate the vector with the entered values. The first entered value will be the first element, the second entered value the second value, etc. Use push_back
Call each function in the order: reverseDisplay(), numOfChar(). Search for x with numChar() Print out the value returned by numOfChar() followed by a new line.
Print Outs
No print outs required other than what reverseDisplay() produces, and the value of numOfChar().
Example run
3 a b x xba <-- reverseDisplay 1<-- numOfChar

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 Programming Questions!