Question: 2 ) You designed and implemented the DC ( Dynamic C ) , which is a new programming language with dynamic scoping. Consider the following

2) You designed and implemented the DC (Dynamic C), which is a new programming language with dynamic scoping. Consider the following code that can be run on both DC and C without any modification.
```
#include
int i =0; int j =
5; int k =10;
void h(void){
printf ("H1: 8d
", i);
i=i+j+k; // Program point 1
printf ("H2: 8d
", i);
}
void g(void){
int k =1000;
printf ("G1: 8d
",i);
i=i+j+k; // Program point 2
h();
printf ("G2: %d
", i);
}
void f(void){
int j =200;
printf ("F1: 8d
", i);
i=i+j+k; // Program point 3
g();
printf ("F2: %d
", i);
}
void main (void){
int i =100;
printf ("M1: 8d
", i);
f();
printf ("M2: 8d
", i);
g();
printf ("M3: 8d
", i);
h(); // Program point 4
printf ("M4: 8d
", i);
}
```
a)What is the output, when the code is compiled with the \(\mathbf{C}\) compiler? Give the referencing environments at program points \(1,2,3\) and 4.
b) What is the output, when the code is compiled with the new DC compiler? Give the referencing environments at program points \(1,2,3\) and 4 for each invocation of the corresponding function. Note that the referencing environment at each invocation might be totally different for the same program point.
2 ) You designed and implemented the DC ( Dynamic

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 Programming Questions!