What is the purpose of default clause in a switch statement?
Answers
Answered by
61
when using switch case we use default case in the end because if the value u have entered do not match with the value in initial expression the the default case runs.
Answered by
10
Purpose of default clause in a switch statement:
Default clause in switch statement works as the same as else clause in if else block. If any of the other case values of the switch statement is not true, the default case will be activated. A switch is a multiple-way statement that gives a simple way to send execution to various parts of codes based on the expression values.
If anything is not matched in a switch statement then nothing could be done without the value default case. In a switch case, it is the exact significance of the default case.
Similar questions