Programming Tools Guide
Chapter 3, C language compiler

Selection statements

Selection statements



if



   if (expression)
        statement


else



   if (expression1)
      statement1
   else if (expression2)
      statement2
   else
      statement3


switch



   switch (expression)
        statement
In practice, statement is usually a compound statement with multiple cases, and possibly a default; the description above shows the minimum usage. In the following example, flag gets set to 1 if i is 1 or 3, and to 0 otherwise:
   switch (i) {
   case 1:
   case 3:
   	flag = 1;
   	break;
   default:
   	flag = 0;
   }