⟩ What is switch case in C++ Syntax?
Switch case statements are a substitute for long if statements that compare a variable to several "integral" values ("integral" values are simply values that can be expressed as an integer, such as the value of a char). The basic format for using switch case is outlined below. The value of the variable given into switch is compared to the value following each of the cases, and when one value matches the value of the variable, the computer continues executing the program from that point.
switch (
case this-value:
Code to execute if
break;
case that-value:
Code to execute if
break;
...
default:
Code to execute if
break;
}