                          Computer Science 101
                               Quiz D      Name ______________________

1. Suppose I run a program as:   a.out  lithuania 400 300
   The value of argc will be:

   a. 3                                  b. 2

   c. 1                                  d. 4

2. If I want to assign the value of the second command line
   parameter (400 in problem 1) to an integer variable called
   width, the correct way to do so is:

   a. sscanf(argv[1], "%d", width);    b. sscanf(argv[1], "%d", &width);

   c. sscanf(argv[2], "%d", width);    d. sscanf(argv[2], "%d", &width);


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

4. Which of the following is the correct way to set the "width" to 600

   a. image_t.width = 600;           b. input.width = 600;

   c. input.width[0] = 600;          d. image_t.width[0] = 600;

5. 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;

