Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c if else if

if (<condition>) {
	<code>
} else if (<condition>) {
	<code>
} else {
	<code>
}

/* 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. */
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
1+4 =