55.7k views
2 votes
Write a program that inputs one character, then display "yes" if the character is ‘y’ , display "no" if the character is ‘n’, displays "menu" if the character is ‘m’, display "exit" if the character is not ‘y’, ‘n’, or ‘m’. Implement this program by a Switch statement.

1 Answer

1 vote

Answer:

#include <iostream>

using namespace std;

int main()

{

char ch;

cout<<"Enter character: ";

cin>>ch;

switch(ch){

case 'y':

cout<<"yes"<<endl;

break;

case 'n':

cout<<"no"<<endl;

break;

case 'm':

cout<<"menu"<<endl;

break;

default:

cout<<"exit"<<endl;

}

return 0;

}

User David Yates
by
6.0k points