switch(ch)
{
case '+':
....cout <<"arithmetic operator";
....break; //<===break is a must
/// <====================other cases
.
.
default: // <=======else
}
Chat with our AI personalities
If you have a loop in your switch statement or around your switch statement, you can use the continue statement in that. You cannot use a continue statement outside of a loop (do, for, or while).
Default clause in switch statement used to indicate that the desired option is not available with the switch case statement. it is similar to else statement of if statement which is used when the condition does not satisfy.
using break; statement
There are two programming languages which use a C switch statement. The two languages are C and C++, hence the name C switch statement. There may be more, but those are the most obvious ones
Ends the case statement. Without it, any code after where the break; is supposed to be will get executed as well until it does encounter a break; or the end of the switch.Code Example:char cTest = 'a';switch(cTest) {case 'a':/* Code here gets executed. */case 'b': //* Code here gets executed. */case 'c':/* Code here gets executed. */break;case 'd':/* Code here won't be executed. */default:/* Code here won't be executed. */}