


#includeĬout<<"The value of addition is= "<

Hence, writing a break in every case statement is essential as it takes us out of the switch case after the execution of that particular case which is the requirement of the question. It is essential to use break statement in all the cases except the default as if we don’t write break in each case statement all the following case gets executed.įor example, in the above code, if we don’t write a break in each case statement, we will get the following output. The value of a there is two hence case 2 gets executed over there Note: Explanation : In the above code, I have passed an in the switch statement.
