Skip to content

PRO TIP Block youtube.com at the DNS level โ€” Pi-hole, NextDNS or your hosts file โ€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Switches in C are easy! ๐Ÿ’ก

17.1K views on YouTube

#coding #programming #cprogramming

// switch = An alternative to using many if-else statements
// More efficient w/ fixed integer values

char dayOfWeek = ‘\0’;

printf(“Enter a day of the week (M, T, W, R, F, S, U): “);
scanf(“%c”, &dayOfWeek);

switch(dayOfWeek){
case ‘M’:
printf(“It is Monday”);
break;
case ‘T’:
printf(“It is Tuesday”);
break;
case ‘W’:
printf(“It is Wednesday”);
break;
case ‘R’:
printf(“It is Thursday”);
break;
case ‘F’:
printf(“It is Friday”);
break;
case ‘S’:
printf(“It is Saturday”);
break;
case ‘U’:
printf(“It is Sunday”);
break;
default:
printf(“Please only enter a character (M, T, W, R, F, S, U)”);
}

return 0;