edited by
7,300 views
11 votes
11 votes

Consider the following program

Program P2
    var n : int;
    
    procedure W(var x : int)
    begin
        x = x + 1;
        print x;
    end

    procedure D
    begin
        var n : int;
        n = 3;
        W(n);
    end

    begin    \\begin P2
        n=10;
        D;
    end

If the language has dynamic scooping and parameters are passed by reference, what will be printed by the program?

  1. 10
  2. 11
  3. 3
  4. None of the above
edited by

2 Answers

Best answer
16 votes
16 votes
answer is D.

here, because of dynamic scoping the value of n passed in w(n) will be n=3.

therefore o/p will be 4, which is not in any option.
edited by
Answer:

Related questions