[prev] [index] [next]

Exercise: If / Switch

Convert the following if to a switch:

if (n == 1) {
	printf("One\n");
} else if (n == 2) {
	printf("Two\n");
} else if (n == 3) {
	printf("Three\n");
} else if (n >= 4 && n <= 9) {
	printf("Real Big\n");
} else {
	printf("Huh?\n");
}