                          Computer Science 101
                               Quiz F      Name ______________________

1. Given the following definitions
   struct pixel_type
   {
      unsigned char r;
      unsigned char g;
      unsigned char b;
   };
   struct pixel_type pixmap[600 * 800];
   which is the correct way to set the red component of element 15 to 250.

   a. pixmap.r[15] = 250;              b. pixmap.[15]r = 250;

   c. pixmap[15].r = 250;              d. pixmap.r[250] = 15;

Given the following definitions
typedef struct image_type
{
   char filename[64];     /* name of disk resident file */
   char id[4];            /* P5 gray or P6 color        */
   int  width;            /* Width in pixel cols        */
   int  height;           /* depth in pixel rows        */
   pixel_t pixels[1024*1024]; /*  The pixel data        */
}  image_t;

struct image_type image;

2. Which of the following is the correct way to set the red component
   of the first pixel:

   a. image[0].pixels.r = 250;       b. image.pixels[0].r = 250;

   c. image.pixels.r[0] = 250;

3. 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

4. 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

5. Suppose the following fwrite() succeeds. What will be the value of
   howmany?

       howmany = fwrite(img->pixels, sizeof(pixel_t), 40000, out);

  howmany =
