Computer Science, asked by ishamehra461, 1 month ago

what is switch statement write its syntax with example​

Answers

Answered by KhadijahSaba
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 sahudivya18350
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