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.

Respuesta :

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;

}

ACCESS MORE