Q44 What is switch and if-else statement? Where do you use switch and if-else? Which one is more efficient?

Please click on link to know about switch statement and if-else statement.

Usually both are equally efficient. The compiler implements them using jump instructions. But each of them has their own unique advantages. It depends on our programming use, if we have to select a case among the n number of cases where n is greater than 2 then use of switch is more efficient.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.