/* The switch statement is often used to process keyboard commands, such as menu selection. */ #include int main(void) { char ch; printf("1. Check Spelling\n"); printf("2. Correct Spelling Errors\n"); printf("3. Display Spelling Errors\n"); printf("Strike Any Other Key to Skip\n"); printf("\tEnter your choice: "); scanf("%c", &ch); //read the selection from the keyboard switch(ch){ case '0': case '1': printf("Checking spelling ... Done.\n"); //break; case '2': printf("Correcting errors ... Done.\n"); break; case '3': printf("Displaying errors ... Done.\n"); break; default: printf("No option selected.\n"); } return 0; } /*Note: 1. The break inside the switch is optional. If the break is omitted, execution will continue on into the next case until either a break or the end of switch is reached. 2. The statement associated with a case could be a null statement. This means that these cases have common statement sequences. */