 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between if-else and switch
In this post, we will understand the difference between if-else statement and ‘switch’ statement.
If-else
- Depending on the expression inside the statement, output would be generated. 
- It uses multiple statements for multiple choices. 
- This statement tests for equality. 
- It can be used to test logical expressions. 
- It can evaluate integer, character, pointer, floating-point type and boolean type. 
- Just one of the ‘if’ or ‘else’ statement gets executed. 
- If the condition inside the ‘if’ statement is false, then the ‘else’ statement is executed if it has been created. 
- It is tough to edit if-else statement, especially if it is nested. 
Switch
- The statement that needs to be executed is decided by the user. 
- It uses a single expression to work with multiple choices. 
- It only tests for equality. 
- It evaluates a character or an integer value. 
- It is easy to edit, since it can be identified easily. 
- It executes one case after another until a break statement is encountered. 
- The ‘break’ statement terminates the switch statement. 
- If the condition inside the switch statement doesn’t match any case, the default statement is executed if it has been created. 
