In the previous section, I have discussed how to use conditional statement in C and C++ language where I showed only if-else statement. Now I shall show you another powerful keyword named switch statement to control program sequence in C and C++.
How switch statement works
When you need to take a decision from multiple choices and select only one choice, you can use switch statement for that case. Say, you need to make a menu in your program. When a user fulfills a condition, he will get a result and when he fulfills another condition, he will find another result and so on. To handle this situation switch is your best friend. Switch statement works with case keyword. When a particular condition will be fulfill within switch, the corresponding case statement will be executed like making switch on or off in your electrical or electronics switch board.