Question

CONCEPTS OF PROGRAMMING LANGUAGE Consider the following program skeleton Procedure Main is X, Y, Z: Integer;...

CONCEPTS OF PROGRAMMING LANGUAGE

Consider the following program skeleton

Procedure Main is

X, Y, Z: Integer;

procedure Sub1 is

A, Y, Z: Integer;

begin -- of Sub1

...

end; -- of Sub1

procedure Sub2 is

A, B, Z: Integer;

begin -- of Sub2

...

end; -- of Sub2

procedure Sub3 is

A, X, W: Integer;

begin -- of Sub3

...

end; -- of Sub3

begin - of Main

...

end; -- of Main

Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last subprogram activated? Include with each visible variable the name of the unit where it is declared.

(a) Main calls Sub1;   Sub1 calls Sub2; Sub2 calls Sub3.

(b) Main calls Sub2;   Sub2 calls Sub3; Sub3 calls Sub1.

(c) Main calls Sub1;   Sub1 calls Sub3; Sub3 calls Sub2.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) Main calls Sub1;   Sub1 calls Sub2; Sub2 calls Sub3.

In the last function call variables are visible

Y

declared in sub1 procedure

B,Z

declared in sub2 procedure

A,X,W

declared in sub3 procedure

--

b) Main calls Sub2;   Sub2 calls Sub3; Sub3 calls Sub1.

In the last function call variables are visible

B

declared in sub2 procedure

X,W

declared in sub3 procedure

A,Y,Z

declared in sub1 procedure

--

(c) Main calls Sub1;   Sub1 calls Sub3; Sub3 calls Sub2.

In the last function call variables are visible

Y

declared in sub1 procedure

X,W

declared in sub3 procedure

A,B,Z

declared in sub2 procedure

--

ALL THE BEST

Add a comment
Know the answer?
Add Answer to:
CONCEPTS OF PROGRAMMING LANGUAGE Consider the following program skeleton Procedure Main is X, Y, Z: Integer;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT