Which of the following statement is false about switch statement.
O A. according to syntax, break statements are mandatory for each case
O B. according to syntax, break statements are not mandatory for each case
O C. Case can take values taken by option of switch statement.
O D. defult case is optional.
Answers
Answered by
6
Answer:
B is false. Because break statement is mandatory. Otherwise the switch will check for all the cases.
Answered by
0
For the switch statement according to syntax, break statement are not mandatory for each case.
Explanation:
Switch statement is used to check the equality against each case or given values.
The break statement is used in switch case is to put an end to the sequence of the statement.
Without the break statement the programs continues to run for next statement until the last statement.
To have multiple cases it is optional to have break statement between them.
If the break statement is not used in switch case it will keep executing till reaching the end of switch.
So option B. is correct.
Similar questions