Computer Science, asked by sumitarout7026, 4 months ago

a) Re-write the following code snippet using switch-case:
if{ v== 1)
P = 1;
else if( *2)
p = 2;
else ifi v==3')
P = 3;​

Answers

Answered by BrainlyProgrammer
1

Question: Convert if-else to switch-case

Answer:

switch (v)

{

case 1: p=1; break;

case 2: p=2; break;

case 3: p=3; break;

}

Explanation:

Note: Default statement is not required in this snippet because 'else' statement is not present in the Question only if-else if statement is present

Answered by anindyaadhikari13
1

Answer:-

This is the converted code snippet.

switch(v)

{

case 1:

p=1;

break;

case 2:

p=2;

break;

case 3:

p=3:

break;

}

Similar questions