Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

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

Discussion in 'General Programming Discussions' started by Swati Mishra, Mar 14, 2016.

  1. Swati Mishra

    Yellow Belt

    Joined:
    Dec 28, 2015
    Messages:
    644
    Ratings:
    +105 / -0
    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;
    }
     
  2. Manish Mishra

    Yellow Belt

    Joined:
    Dec 22, 2015
    Messages:
    1,025
    Ratings:
    +159 / -0
    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.
     

Share This Page