                          Computer Science 101
                               Quiz E        Name ______________________

1. Given the following definitions circle ALL of the following
   assignments that are syntactically correct:

   struct pix                   struct pix  p1;
   {                            struct pix *p2;
      unsigned char r;
      unsigned char g;
      unsigned char b;
   };

   a. p1->r = 250;                     b. p2->r = 250;

   c. p2.r = 250;                      d. p1.r  = 250;

2. Given the prototype: void blue_pix(struct pix *p);
   Suppose the caller of blue_pix() has declared:
   struct pix pixval;
   The syntactically correct way to invoke blue_pix is:

   a. blue_pix(pixval);                b. blue_pix(*pixval);

   c. blue_pix(&pixval);               d. all of these work fine

3. Now suppose the prototype is: void blue_pix(struct pix p);

   The syntactically correct way to invoke blue_pix is:

   a. blue_pix(pixval);                b. blue_pix(*pixval);

   c. blue_pix(&pixval);               d. all of these work fine


4. Suppose the mission of blue_pix() is to set the color of
   the callers pixel to blue (r = 0, g = 0, b = 255). Which
   best characterizes the approaches used in questions 2 and 3:

   a. both will correctly set          b. question 2 will set pixval
      pixval to blue.                     to blue but question 3 won't
                                          modify pixval.

   c. neither approach can be used     d. question 3 will set pixval
      to modify pixval.                   to blue but question 2 won't
                                          modify pixval.

5. Suppose an image has width 300 and height 200.  The index in the
   pixel array of the pixel at row 3 col 52 is:

   ndx =



