Home › C Tutorial › C switch
C switch
Many choices on one value.
Each case needs break or execution falls through. default catches the rest.
Example code
#include <stdio.h>
int main() {
int d = 3;
switch (d) {
case 1: printf("Mon\n"); break;
case 3: printf("Wed\n"); break;
default: printf("Other\n");
}
return 0;
}