If-Else V.S. Switch end of flow
- by Chris Okyen
I was wondering the if if-else statements, is like a switch statement that does not have a break statement.To clarify with an example, will the if-else statement go through all the boolean expressions even if comes to one that is true before the final one... I.E., if boolean_expression_1 was true, would it check if boolean_expression_2 is true? If not, why do switch statements need break statements but if-else statements do not? And if they do, I ask the opposite sort question proposed in the previous sentence.
if( boolean_expression_1 )
statement_1
else if( boolean_expression_2 )
statement_2
else
default_statement
switch( controlling_expression )
{
case: ( A )
....
case: ( z )
}