if else en c code example
Example 1: c if else
if () {
} else if () {
} else {
}
/* example */
int money = 50;
if (money < 15) {
go_home();
} else if (money >= 600) {
buy_all();
} else {
buy_tickets(money / 15);
}
/* You can chain together as many else ifs as you want. But if there are
too many it will make the code hard to understand. In that case I would
recommend trying other solutions. */
Example 2: if statement in c
#include
int main()
{
if (logic goes here)
{
CODE
}
else if (logic)
{
CODE
}
else{
CODE
}
return 0
}