1,537 views
5 votes
5 votes

Indicate the result of the following program if the language uses (i) static scope rules and (ii) dynamic scope rules.

        var x, y:integer;
        procedure A (var z:integer);
        var x:integer;
        begin x:=1; B; z:= x end;
        procedure B;
        begin x:=x+1 end;
        begin
        x:=5; A(y); write (y)
...end.

1 Answer

3 votes
3 votes
Using static rules, we get 1.

Using dynamic rules, we get 2

Related questions

3 votes
3 votes
1 answer
1
makhdoom ghaya asked Dec 5, 2016
1,270 views
Will recursion work correctly in a language with static allocation of all variables? Explain.
1 votes
1 votes
1 answer
4
makhdoom ghaya asked Nov 30, 2016
725 views
Consider the definition of macro $B,$ nested within the definition of a macro $A.$ Can a call to macro $B$ also appear within macro $A?$ If not, why not? If yes, explain ...