Computer Science, asked by humanbeing25, 1 year ago


1. When do we use the switch case statement? explain with syntax & example?​

Answers

Answered by ayushmanankit
9

Answer:

We use switch case when the user should choose between different items

Explanation:

Switch (control variable)

{

Case 1:

Statement 1;

Break;

Case 2:

Statement 2;

Break;

Default :

System.out.println("Wrong choice") ;

}

Example:

Switch(ch)

{

Case a:

System.out.println("a=" +a) ;

Break;

Case b:

System.out.println("b=" +b) ;

Break ;

Default:

System.out.println("Wrong choice") ;

}

I hope ur doubt is cleared

Plz mark my answer as the brainliest

Similar questions