                          Computer Science 101
                                Quiz J      Name ______________________


1. Which is the proper way to dynamically allocate storage for an
   array of 100 integers. (For questions 2, 3, 4 assume that the
   pointer variable loc is declared as: int *loc;

   a. loc = (int *)malloc(sizeof(int) * 100);   b. loc = (int *)malloc(100);

   c. loc = (int *)malloc(4 * sizeof(int));


2. Suppose the values of the 100 integers are to be printed in a
   for () loop.  In each interation through the loop, the proper
   way to update the pointer used to point to the value to be
   printed is:

   a. loc = loc + 4;                      b. loc = loc + 1;

   c. loc = loc + sizeof(int);            d. loc = loc + 100;


3. The proper way to print the value of the current integer is:

   a. printf("%d \n", &loc);             b. printf("%d \n", loc);

   c. printf("%d \n", *loc);


4. The proper way to read an element into the array is:

   a. scanf("%d", &loc);             b. scanf("%d", loc);

   c. scanf("%d", *loc);

