what is switch statement write its syntax with example
Answers
Answered by
1
Explanation:
A general syntax of how switch-case is implemented in a 'C' program is as follows: switch( expression ) { case value-1: Block-1; Break; case value-2: Block-2; Break; case value-n: Block-n; Break; default: Block-1; Break; } Statement-x; The expression can be integer expression or a character expression.
Answered by
2
Answer:
switch(expression)
{
case constant value::
block of statements
.
.
.
break;
case consumer value 2;
block of statements
.
.
.
break;
case constant value 3
block of statements
.
.
.
break;
default:statement n;
}
Explanation:
Examples- Switch (choice)
{
case1
system. out.println("sunday");
break;
.
.
case7;
system. out.println("Saturday ");
default;
system. out.println("wrong input");
}
I HOPE IT IS HELPFUL FOR YOU ❤
Similar questions
Social Sciences,
23 days ago
Math,
23 days ago
English,
23 days ago
Social Sciences,
1 month ago
History,
1 month ago
Math,
9 months ago
Math,
9 months ago
Math,
9 months ago