what is difference between if else and switch statement
  • what is difference between if else and switch statement
    Thank You
    Regards,
    M.Hussain
    Software Engineer
  • 1 Comment sorted by
  • Both similar but some features are
    Switch:
    The switch statement evaluates an expression, which must have an integral result. Based on that result, a branch is taken to one of the case statements, or to the default statement if present and none of the case statements match.

    Note that the case statement represents a "goto" type of operation. If it is intended that each case execute without executing the following case statement(s), then each case must include a break statement.

    If-else:

    The if-else statement evaluates an expression, which must have a logical result. If the result is true, the first target statement executes - if false, the second target statement executes.



Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative