/* * Example of the switch statement with type char case labels * * Hanly and Koffman, 5ed, Figure 4.12, page 191 * */ #include int main(void) { char class; printf("Input the ship class ID >"); scanf("%c", &class); switch (class) { case 'B': case 'b': printf("Battleship\n"); break; case 'C': case 'c': printf("Cruiser\n"); break; case 'D': case 'd': printf("Destroyer\n"); break; case 'F': case 'f': printf("Frigate\n"); break; default: printf("Unknown ship class %c\n", class); } return 0; }