Advertisements
Advertisements
Question
Write the general syntax for switch statement.
Advertisements
Solution
The syntax of a switch statement: switch (expression)
switch(expression)
{
case label1:
statements1;
break;
case label2:
statements2;
break;
case labeln;
statements - N;
break;
default:
statements;
}APPEARS IN
RELATED QUESTIONS
Which conditional statement is used to transfer control from current statement to another statement?
Which statement in switch case is used to exit the statement once the appropriate choice is found?
In which loop the condition is evaluated, before executing a statement?
What is meant by conditional statements in JavaScript?
Differentiate the break and continue statement.
What is if statement and write its types.
Write the syntax for else-if statement.
What message will be displayed, if the input for age is given as 20, for the following snippet?
Explain switch case statement with example.
Which of the following is not true with regards to a switch statement?
