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


Please write your Name, Student ID, and Section at the top of the page.
  1. [Pts 2] What is the effect of a command (or statement) in an imperative language (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

  2. [Pts 2] What is the effect of a declaration in an imperative language (only one answer, please)

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

  3. [Pts 2] In an imperative language, can an assignment to x change the value of y? (only one answer, please)

    1. no, never
    2. yes, if x and y have the same value
    3. yes, if x and y are associated to the same location (aliasing)
    4. yes, if x and y are not declared in the same block

  4. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 1;
            begin y in y := x; x := x + 1 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 = x + 1; } c;
    
    Answer: 2

  5. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 1;
            begin x in x := 2 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 x = 2; } c;
    
    Answer: 1