Q44 What is switch and if-else statement? Where do you use switch and if-else? Which one is more efficient?
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.