Switch Statement
Switch Statement
control statement in C.
It allows a variable to be
tested for multiple values.
Switch
statement
Each value is called a case.
Used as an alternative to
multiple if-else statements
syntax
switch(expression) {
case value1:
// Statements
break;
case value2:
// Statements
break;
default:
// Statements
}
expression is evaluated once.
Add
Subtract
Multiply
Divide
Use a switch statement to perform the selected operation.
R: Stop
Y: Ready
G: Go