Spring 2001, CSE 428: Quiz 4.3 - 8 Feb 2001


Please write your Name, Student ID, and Section at the top of the page.
  1. [Pts 2]

    A function which uses call by value can only be (only one answer please)

    1. strict
    2. free from side-effects (namely, cannot modify the state)
    3. implemented using a stack-based machine
    4. evaluated at compile-time

  2. [Pts 3]

    For each of the following parameter passing methods, say whether a change on the formal parameter can affect the value of the actual parameter (assuming that the latter is a variable) or not

    1. call by value     no
    2. call by value-result     yes
    3. call by reference     yes

  3. [Pts 3]

    Consider the following procedure and fragment of code in C++ like. Assume that y is a global variable.

       void p(int ... x){ x = x+1; y = y+2; cout << x; }
       ...
       y = 1;
       p(y);
       ...
    
    What is the value printed by the instruction cout << x; under each the following parameter passing methods:

    1. call by value     2
    2. call by value-result     2
    3. call by reference     4

  4. [Pts 2]

    In a stack-based implementation of a programming language, the stack is used during the execution to dynamically allocate and deallocate storage for (only one answer, please)

    1. the dynamic variables
    2. the local variables
    3. the global variables
    4. the code of the functions/procedures which are being called