c++ switch case character code example
Example 1: c++ switch case statement
switch (n)
{
case 1: // code to be executed if n = 1;
break;
case 2: // code to be executed if n = 2;
break;
default: // code to be executed if n doesn't match any cases
}
Example 2: switch case c++
// Transfers control to one of the several statements, depending on the
//value of a condition.
switch (variable or an integer expression) {
case constant: {
//C++ code
break;
}
case constant: {
//C++ code
break;
}
default: {
//C++ code
break;
}
}
Example 3: c++ switch case
switch(expr) {
case 1:
// do something
break;
case 2:
// do something
break;
default:
// do something
}