Example: default

In the following example, control passes to the default statement because the variable menu, whose value is 4, does not appear in any specific case statement.

    int menu = 4;
    switch(menu) {
    case 1: 
        lr_output_message ("Option 1");
        break;
    case 2:
        lr_output_message ("Option 2");
        break;
    case 3:
        lr_output_message ("Option 3");
    default:
        lr_output_message ("Invalid option selected\n");
}
Output:
Action.c(16): Invalid option selected