switch StatementThe switch statement provides an alternative to using multiple if else statements. It evaluates an expression and executes the corresponding case block.
switch statement evaluates the value of grade and matches it with the corresponding case.break statement exits the switch block to prevent fall-through.default case is executed if no matching case is found.void main() {
String grade = 'B';
// Switch statement
switch (grade) {
case 'A':
print('Excellent');
break;
case 'B':
print('Good');
break;
case 'C':
print('Fair');
break;
case 'D':
print('Poor');
break;
default:
print('Invalid grade');
}
}