1. When do we use the switch case statement? explain with syntax & example?
Answers
Answered by
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
Physics,
11 months ago
Social Sciences,
11 months ago
Physics,
1 year ago
Math,
1 year ago
Math,
1 year ago