CASE Statements

Only Pascal does not offer defaults in CASE statements.

Visual FoxPro BASIC
DO CASE
 CASE n = 0
  ? 'Zero'
 CASE n > 0
  ? 'Pos'
 OTHERWISE
  ? 'Neg'
ENDCASE
Select Case n
 Case 0
  Print 'Zero'
 Case Is > 0
  Print 'Pos'
 Case Else
  Print 'Neg'
End Select
Pascal C/C++
case n of
 0: writeln("Zero");
 1: writeln("One");
end
switch(n) {
 case 0:
  printf("Zero\n");
  break;
 case 1:
  printf("One\n");
  break;
 default:
  printf("?\n");}

See Also

Assignment Statements | Case Sensitivity | Comments | FOR Loops | IF Statements | Parameter Passing by Reference | Parameter Passing by Value | Variable Declaration | WHILE Loops