Give Two Differences Between the Switch Statement and the If-else Statement.
Advertisements
Question
Give two differences between the switch statement and the If-else statement.
Distinguish Between
Advertisements
Solution
| S. No. | Switch statement | if-else statement |
| 1. | In this statement, multicodes can be provided in which control transfers to different parts of the code based on the value of an expression. | In this statement, only two codes are based on either a true or a false condition. |
| 2. | Syntax:
|
Syntax:
|
shaalaa.com
Introduction of Object-oriented Programming
Is there an error in this question or solution?
