The Gateway to Computer Science Excellence
0 votes
295 views

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.
in Compiler Design by Boss (31.2k points) | 295 views

1 Answer

+1 vote
Using static rules, we get 1.

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

@kapilbk1996 @Verma Ashish

What value of y is passed when we make a call to procedure A (i.e. A(y))

0
@ayushsomani it should be 0

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,833 questions
57,736 answers
199,463 comments
107,933 users