ICSE 10th Standard Notes – Difference between Switch and If-Else Statements

ICSE 10th Standard Notes – Difference between Switch and If-Else Statements

S.No.

Switch Statement

If-Else Statements

Switch can test only for Equality. If can evaluate relational and Logical expression.
Switch can test only one condition. If-Else can test multiple condition.
Switch statement selects its branches by testing the value of same variable. If-Else lets you to conduct a series of expressions that may involve unrelated variable and complex expression.
Switch case label must be a single value. The If-Else statements is more versatile of two statements.
Switch Statements cannot handle Floating point Tests. The If-else statements can handle Floating point Tests.
The switch case label value must be a constant. If-Else statement is used for two or more variables.
The switch statement is more efficient in code used in a situation that supports the nature of switch statement. The If-Else statement is more efficient where a series of expression are to be evaluated.

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: