Basic

Switch Statement

views

7:08
We use if when we have 2 options in front of us. But if we have more than 2 options and for each option we have to give a different set of commands then we make use of switch. Imagine that there is an election being conducted in your area and you want to write a program which will register your vote and give you the results as soon as the election is over. The program will look like this.