• Home
  • Game
  • C++
  • Java
  • Android
  • No Need
  • Switch, Case, Default Statements In C++

    Switch case is uses as alternative of if….else. When we need to use long term of if…else then we use switch case for reducing program execution time.

    Case value 1:
    Case value 2:


    In the switch variable we put the value which needs to match with case value. The value of variable are compare with all case value , if any of them are match with switch variable then program execute that case statement. If there are no matches found or false value passed  in the switch variable then it execute default statement.

    Here break keyword are use for end that particular process, that means break keyword stop the switch statement process. The break key word can execute only then, when any of the case can executed.

    If this program get integer value within 1 to 3 then its execute the case values.

     If we pass any kinds of value without case value, then the program execute the default statement

    Here flowchart are provided for understand more easily .

    Flow chart 
    Share this article :
    Support : Prosanta Chaki |
    Copyright © 2011. Funny Programmer - All Rights Reserved
    Proudly powered by Blogger