When working with a SWITCH, the "default" label will ALWAYS be executed or it will only be executed if theres no other CASE match?
Example:
int a=1;
switch(a) {
case a=1:
something;
case a=2:
something;
case a=3:
something;
default:
somethingelse;
}
One more, in the above example, as theres no BREAK inside any of the cases, my program will try to match "a" against the second and he third cases and probably the default too?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You need to review the syntax for the switch statement. Yes, you should have a break at the end of each clause unless you INTEND for the code to fall through. But also your 'case' clauses should look like 'case 1:', not 'case a=1:'
qWake
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
switch(cases) // ............ start switch
{
case 1: // ..... Checks for first value
sfunct(); // ... calls the function
break; // If value one then ends here
case 2: // ..... Checks for second value
mfunct(); // ... calls the function
break; // If value two then ends here
case 3: // ..... Checks for thrid value
dfunct(); // ... calls the function
break; // If value three then ends here
default: // If not any of the above then this massage will print to screen.
cout << "The Number "<< system << " Is not a Function. \n" ;
break;
} // ........................ end switch
N@N!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When working with a SWITCH, the "default" label will ALWAYS be executed or it will only be executed if theres no other CASE match?
Example:
int a=1;
switch(a) {
case a=1:
something;
case a=2:
something;
case a=3:
something;
default:
somethingelse;
}
One more, in the above example, as theres no BREAK inside any of the cases, my program will try to match "a" against the second and he third cases and probably the default too?
Ouch!
You need to review the syntax for the switch statement. Yes, you should have a break at the end of each clause unless you INTEND for the code to fall through. But also your 'case' clauses should look like 'case 1:', not 'case a=1:'
qWake
switch(cases) // ............ start switch
{
case 1: // ..... Checks for first value
sfunct(); // ... calls the function
break; // If value one then ends here
case 2: // ..... Checks for second value
mfunct(); // ... calls the function
break; // If value two then ends here
case 3: // ..... Checks for thrid value
dfunct(); // ... calls the function
break; // If value three then ends here
default: // If not any of the above then this massage will print to screen.
cout << "The Number "<< system << " Is not a Function. \n" ;
break;
} // ........................ end switch
N@N!