Difference if..else n switch.

Q1. How is the if..else if combination more general than a switch statement?

Or

Q1. Difference between if..else if combination and a switch statement?

Ans. The switch statement must be controlled by a single integer control variable, and each case section must correspond to a single constant value for the variable.

The if.. else if combination allows any kind of condition after each if.  

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s