1if (condition)
2{
3 //Block of C statements here
4 //These statements will only execute if the condition is true
5}
1#include <studio.h>
2int main()
3{
4 if (logic goes here)
5 {
6 CODE
7 }
8 else if (logic)
9 {
10 CODE
11 }
12 else{
13 CODE
14 }
15 return 0
16}
1if (<condition>) {
2 <code>
3} else if (<condition>) {
4 <code>
5} else {
6 <code>
7}
8
9/* example */
10int money = 50;
11if (money < 15) {
12 go_home();
13} else if (money >= 600) {
14 buy_all();
15} else {
16 buy_tickets(money / 15);
17}
18
19/* You can chain together as many else ifs as you want. But if there are
20too many it will make the code hard to understand. In that case I would
21recommend trying other solutions. */
1char o = '+'; //Or some other character
2
3if (o == '%' || o == '/' || o == '*' || o == '+' || o == '-') {
4 //Do something
5 //...
6}
1if (test expression1) {
2 // statement(s)
3}
4else if(test expression2) {
5 // statement(s)
6}
7else if (test expression3) {
8 // statement(s)
9}
10.
11.
12else {
13 // statement(s)
14}
1if ( TRUE ) {
2 /* Execute these statements if TRUE */
3}
4else {
5 /* Execute these statements if FALSE */
6}
7