next up previous contents index
Next: while Up: Control Structures Previous: Control Structures   Contents   Index


if

The if statement has a simple syntax:

  
if (a < b) {
  /*  things to if a < b  */
}
/* .. */
if (a < b) {
  /*  things to do if a < b  */
} else {
  /*  things to do if a >= b  */
}
If the compound-statements only contain a single command, the curly brackets can be omitted. For example:

  
if (a < b) a = b;
/* .. */
if (a < b) a = b;
else a = a+1;



CATAM admin 2010-02-23