switch function c++ code example
Example 1: switch statement c++
switch(expression) {
case constant-expression :
statement(s);
break; //optional
case constant-expression :
statement(s);
break; //optional
// you can have any number of case statements.
default : //Optional
statement(s);
}
Example 2: switch in c++
switch (variable) {
case 1:
// code here
break
default:
// code here
break
}