89.2k views
2 votes
Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y, the message "Your request is being processed" is printed if response is n, the message "Thank you anyway for your consideration" is printed if response is h, the message "Sorry, no help is currently available" is printed for any other v

User Oehmiche
by
4.4k points

1 Answer

3 votes

Answer:

# include<iostream>

#include<conio.h>

using namespace std;

main()

{

char choice;

cout<<"Enter your Choice"

cin>>choice;

switch (choice)

{

case 'y':

cout<<"Your request is being processed";

break;

case 'n':

cout<<"Thank you anyway for your consideration";

break;

case 'h':

cout<<"Sorry, no help is currently available";

default:

cout<<"Incorrect Choice";

break;

}

getch();

}

Step-by-step explanation:

In this program, a character type variable named as choice is selected for the input. This choice variable can be y, n or h as per requirement of the program. Switch statement is chose for the selection of output statement with respect to its mentioned input. This program shows the output statement for above mentioned characters. In case of any other character the program returns Incorrect choice and ends.

User Rowan Miller
by
3.8k points