1,658 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

1.4k
views
1 answers
3 votes
makhdoom ghaya asked Dec 5, 2016
1,359 views
Will recursion work correctly in a language with static allocation of all variables? Explain.
4.7k
views
1 answers
21 votes
Cruise Device asked Jan 22, 2016
4,748 views
In which of the following case(s) is it possible to obtain different results for call-by-reference and call-by-name parameter passing?Passing an ... as a parameterPassing a pointer as a parameterPassing as array element as a parameter
771
views
1 answers
1 votes
makhdoom ghaya asked Dec 5, 2016
771 views
Consider the following grammar for variable declarations:<vardecl> $\rightarrow$ <vardecl><idlist> : <type>;<vardecl> $\rightarrow \in$ ... procedures operating on the symbol table; you need not elaborate upon these procedures.
767
views
1 answers
1 votes
makhdoom ghaya asked Nov 30, 2016
767 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 if there are any restrictions.