Answer to Quiz 8(a) Tue 16 Oct 2001

1. Use typedef to define the enumeration type season
   which takes the values winter, spring, summer, and fall.

      enum season { winter, spring, summer, fall };
      typedef  enum season  season;

2. With the type you defined above,
   give the definition of the function 

      season next_season ( season s );
      /* returns the season following the season s */

      season next_season ( season s )
      {
         return ( (season) (( (int) s+1) % 4 ));
      }

alternative :

      season next_season ( season s )
      {
         switch(s)
         {
            case winter : return spring;
            case spring : return summer;
            case summer : return fall;
            case fall   : return winter;
         }
      }