Quiz 9.4

DIRECTIONS: Read each question carefully. Then click on the dot next to the answer that most closely fits the question. Try to answer all questions on this quiz and when you are done, click on the grade me button at the bottom.


Coverage: Section 9.7

  1. Which operator is the address-of operator in C?
|
&
*
[]

  1. What do we call it when we follow a pointer to the object its points to, and get that object?
dereferencing
referencing
pointer arithmetic
indirect access

  1. Which chunk of CSC-1 assembler code gets the value that is pointed to by variable POINTR and puts it into the A register?
     LOD POINTR
     A2S
     STS

     LOD POINTR
     A2S
     LDS

     LOD POINTR
     S2A
     LDS

  1. How does the pointer program work its way through each element of the array in the example program of section 9.7 where an array of integers is summed up?
it adds the base address of the array to the current value of the index variable and gets the value that way; then it increments the index
it adds 1 to the base address and follows the pointer to the value in memory
it gets the value from the array by following the pointer to it, then adds 1 to the pointer for the next round

  1. If pointers and arrays are actually equivalent for this example, why do we even need pointers?
not all data structures can be easily represented by arrays; graphs and linked lists are better represented by pointers
a program that uses arrays tends to run slower than one that uses raw pointers
most people find arrays more confusing and difficult to understand than pointers; hence it is a human factors issue

  1. An array has a name in a high level language like C. For example, STUFF might be an array of integers. What would the name STUFF correspond to in assembler?
the entire array STUFF
the address of the first element of STUFF
the address of the last element of STUFF