My 2 Cents How To Use Switch …..case In C++

Swati Mishra

Yellow Belt
Switch…Case is used when there are multiple values for the variable. When the Switch statement is executed, its condition variable is also evaluated and compared with the Case constant. If one of the case constant is equal to the condition variable, control is passed to the statement following the matched case label. If no any Case match to the condition variable, control is passes to the statement with the default label. The break statement is used for the exit the switch statement.
Syntax
Switch (variable name)
{
Case constant_ expression_1:
Statements;
Break;
……..
………
Case constant_ expression_n:
Statements;
Break;
Default:
Statements;
}
 

Manish Mishra

Yellow Belt
Switch case is totally different that Looping function and If-Else structure.
This is the case when it does not go ahead in the programme once the condition gets true or false. It is totally like grabbing the condition and get out of the programme. If by chance no conditions get true then there is default case need to as output.
 
Top