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

Nested if statements are easy! ๐ŸŽŸ๏ธ

18.6K views on YouTube

#coding #programming #cprogramming

float price = 10.00;
bool isStudent = true; // 10% discount
bool isSenior = true; // 20% discount

// student = $9
// senior = $8
// student + senior = $7

if(isStudent){
if(isSenior){
printf(“You get a student discount of 10%\n”);
printf(“You get a senior discount of 20%\n”);
price *= 0.7;
}
else{
printf(“You get a student discount of 10%\n”);
price *= 0.9;
}
}
else{
if(isSenior){
printf(“You get a senior discount of 20%\n”);
price *= 0.8;
}
}

printf(“The price of a ticket is: $%.2f\n”, price);

return 0;