I want to know how to do Switch statement? When user enters Y it will exit and if user enter N, the program will redisplay the menu. Im stucked here.
Hence this is the sample output desired.
//declare variable
char decision = ' ';
//determine output
switch (decision)
{
case'Y':
//put output code here...
break;
case'N':
//put output code here...
break;
default:
/*put things like error messages
in here -- chosen if no other
match is found*/
} //end switch
#include<iostream>
using namespace std;
#include<conio.h>
int main() {
string a;
cin>>a;
switch (string(a)) {
case "Option 1":
cout<<"It pressed number 1"<<endl;
break;
case "Option 2":
cout<<"It pressed number 2"<<endl;
break;
case "Option 3":
cout<<"It pressed number 3"<<endl;
break;
default:
cout<<"She put no choice"<<endl;
break;
}
return 0;
}