Difference Between Switch and If-Else – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-ICSE2014-02C #JAVA#3918    siteicon   siteicon  

Problem Statement - Difference Between Switch and If-Else

Give two differences between switch statement and if-else statement.

Solution

TC++ #3918

Two differences between switch and else statements are as follows –

1) Switch statement can test on comparison for equality while if-else can handle any kind of comparison, relation and combinations.

2) Switch allows equality comparison for primitive data types and string only, while if-else can handle all data types.


Share

sunmitra| Created: 21-Mar-2018 | Updated: 17-Apr-2019|ICSE2014









Back