Question: Please answer in C++ format: Below is the header for a C++ function. void get_choice(string &ch) The function should ask the user to enter a
Please answer in C++ format:
Below is the header for a C++ function.
void get_choice(string &ch)
The function should ask the user to enter a single character (as string), and you can assume the user will type in just 1 character. If they enter either y, Y, n, or N, then that character should be assigned to the string parameter ch, and the function should end. If the user enters any other character, the function should keep asking the user to re-enter a valid character until they type either y, Y, n, or N.
Write a second version of get_choice that uses the function return mechanism to return the value of a string variable ch entered by the user (instead of a reference parameter). Name this second function get_choice2.
int main() { string character; // write your code below //call get_choice cout<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
