Spring 2001, CSE 428: Quiz 3.2 - 1 Feb 2001


Please write your Name, Student ID, and Section at the top of the page.

  1. [Pts 2] What does the environment represent in an imperative language (only one answer, please)

    1. the associations between identifiers and locations
    2. the associations between locations and values
    3. the result of all the expressions in the program
    4. the result of the type-checking

  2. [Pts 2] What is the result of the evaluation of an assignment (only one answer, please)

    1. it changes the environment
    2. it changes the state
    3. it checks that the program is statically correct
    4. it checks that the program is dynamically correct

  3. [Pts 2] Which parameters determine the result of the evaluation of a command (only one answer, please)

    1. the current state alone
    2. the current environment alone
    3. the current state and the current environment together
    4. the result of all previous expressions in the program

  4. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 1;
            begin y in x := x + 2; y := x  end;
            c
       end
    
    What is the value of x at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int x = 1; { int y; x = x + 2; y = x; } c;
    

    Answer: 3

  5. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 2;
            begin x in x := 3 end;
            c
       end
    
    What is the value of x at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int x = 2; { int x = 3; } c;
    

    Answer: 2