Many of you may say that there no difference between these two statements but you are wrong. Both of these powerful statements have their pros and cons.

The IF statement can be used to test conditions so that we can alter the flow of a program. In other words: if a specific statement is true, execute this instruction. If not true, execute this instruction.

The switch statement is almost the same as an IF statement. The switch statement can have many conditions. You start the switch statement with a condition. If one of the variables equals the condition, the instructions are executed. It is also possible to add a default. If none of the variable equals the condition the default will be executed.

Both of these statements are useful in different cases, there are task that cannot be performed by IF statements that can be done by switch and vice versa.