The Gateway to Computer Science Excellence
0 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;
        x:=5; A(y); write (y)
in Compiler Design by Boss (30.2k points) | 258 views

1 Answer

+1 vote
Using static rules, we get 1.

Using dynamic rules, we get 2
by (403 points)
If it is call by value then value of z inside procedure A will not affect value of y

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,557 answers
101,584 users