Question: (20pt) Consider the following program in a language where variables are automatically initialized with 0 and x, y, z are constants that were defined before

 (20pt) Consider the following program in a language where variables are

(20pt) Consider the following program in a language where variables are automatically initialized with 0 and x, y, z are constants that were defined before the program fragment shown. int a; f(n) { a = n; } g() { print a; } h() { f(x); g(); } k() { int a; g(); f(y); } f(z); g(); k(); g(); h(); g(); (1) (16pt) Give the output of the program for (a) static scoping and (b) dynamic scoping. Explain your answer by running the program in each case step by step, including full details concerning variable assignments and output of print statements. (2) (4pt) Find for what values of x,y,z the output of the program is the same with static or dynamic scoping

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!