+ 1
How to use a switch statement to output values of multiple variables?
The code is supposed to output according to the user defined values of multiple variables using a single switch statement. I'm a beginner btw.
2 Answers
0
use
switch(value){
case match1:
//do something
break;
case match2:
//do something else
break;
.......
default:
//do final if none of the above matched
//break optional only here but compulsion after each case
}
0
switch (choice)
{
case 1:
{
// All the executive code you want to perform
break;
}
case 2:
{//your codes
break;
}
default :
{
your code for default statement
break;
}
}