Question: 1 2 points ] Consider the following program: c Copy code program scopetest / / global variables int a; int b; int p = 0

12 points] Consider the following program:
c
Copy code
program scopetest // global variables int a; int b; int p =0; procedure x(){ int a; a =0; b =1; p =2; } procedure printvars(){ println(a); println(b); println(p); } procedure q(){ int b; a =3; b =4; p =5; printvars(); }// Main Body is here: x(); // run procedure x a = p; // store p in a q(); // run procedure q // End of Main Body
Show what the program would print out assuming the language uses:
A) Static scope rules (6 points)
B) Dynamic scope rules (6 points)

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!