Chapter 2 Decision Making
Chapter 2 Decision Making
• The if statement
• The if-else statement
• The conditional operators
• C uses the keyword if to implement the decision control
instruction. The general form of if statement looks like this:
• if ( this condition is true )
execute this statement ;
• The keyword if tells the compiler that what follows is a
decision control instruction. The condition following the
keyword if is always enclosed within a pair of parentheses.
• If the condition, whatever it is, is true, then the statement is
executed.
• If the condition is not true then the statement is not
executed; instead the program skips past it.
How to evaluate condition?