if (a == 2) { // if a is equal to 2 foo++; // increment the variable foo bar = foo + 10; // assign the value of foo plus 10 to bar } else { // otherwise (a is not equal to 2) foo--; // decrement foo bar = foo - 10; // assign the value of foo minus 10 to bar }Note the increment and decrement operators, ++ and -. The keyword if is followed by an expression in parentheses that evaluates to a number. If the expression evaluates to a number other than zero, then the statements in braces immediately following are evaluated. If the expression evaluates to 0, anything following the else in braces will be evaluated. If there are no braces, then only the next line will be evaluated. An if does not need to be followed by else: you may only want something to be done in one case of the condition, and not in others.
The conditional expression normally has a relational operator. The relational operators take two arguments and evaluate to 1 if the relation is true and 0 if it is false. The operators are:
== equality
!= inequality
< less than
> greater than
<= less than or equal to
>= greater than or equal to
Note the difference between the equality operator == and the assignment operator =. This is one of the most common sources of bugs in C programming.