Switch statement

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.
WARNING! Queue is not empty. Proceed? [Y/N]: Y


Here's the format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//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 
Last edited on
Lbkulinski


thank you my friend.
No problem
We can also apply this code:

#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;
}
camycent wrote:
We can also apply this code:
No, that doesn't work with C/C++.
Topic archived. No new replies allowed.