09C. Standards for If-Statements

See the standards for if-statements and conditionals.


Exercises

  1. The coding standards forbid the following.

      if(n == 0){}
      else
      {
        z = 1;
      }
    
    Rewrite that into an acceptable form that does the same thing. Answer

  2. The coding standards disallow the following. Explain what is going on and how to avoid this.

      if(x == 0)
      {
        y = 1;
      }
      else if(x != 0)
      {
        y = 2;
      }
    
    Answer