Ask Question

Consider the following program:

void fun1 (void); / * prototype * /

void fun2 (void); / * prototype * /

void fun3 (void); / * prototype * /

void main () {

int a, b, c;

...

}

void fun1 (void) {

int b, c, d;

...

}

void fun2 (void) {

int c, d, e;

...

}

void fun3 (void) {

int d, e, f;

...

}

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

1. main calls sub1; sub1 calls sub2; sub2 calls sub3.

2. main calls sub1; sub1 calls sub3.

3. main calls sub2; sub2 calls sub3; sub3 calls sub1.

4. main calls sub3; sub3 calls sub1.

5. main calls sub1; sub1 calls sub3; sub3 calls sub2.

+1
Answers (1)
  1. 2 February, 01:24
    0
    Following are the variables which is visible in when the last module is called:

    d, e, f d, e, f b, c, d b, c, d c, d, e

    Explanation:

    Missing information:

    The above question option needs to holds the function name as fun1, fun2 or fun3, but the options are holding the sub1, sub2, and sub3. The above question asked about the variable when the last function is called. The explanation of the visible variable is as follows: For the first option, the last function is called is fun3 which holds the variable as d, e, and f, and no variable is passed as the argument, So currently visible variable are d, e, and f. For the second option, the last function is called is fun3 which holds the variable as d, e, and f, and no variable is passed as the argument, So currently visible variable are d, e, and f. For the third option, the last function is called is fun1 which holds the variable as b, c and d and no variable is passed as the argument, So currently visible variable are b, c, and d. For the fourth option, the last function is called is fun1 which holds the variable as b, c and d and no variable is passed as the argument, So currently visible variable are b, c, and d. For the fifth option, the last function is called is fun2 which holds the variable as c, d and e and no variable is passed as the argument, So currently visible variable are c, d, and e.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the following program: void fun1 (void); / * prototype * / void fun2 (void); / * prototype * / void fun3 (void); / * prototype * / ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers