dynamic scoping

dano's Avatar, Join Date: Jun 2009
Newbie Member
Can someone help me understand dynamic scoping with this example?
void fun1(void);      /*prototype*/
void fun2(void);     /*prototype*/
void fun3(void);     /*prototype*/

void main () {
    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 sequence and assuming that dynamic scoping is used, what variales are visible during execution of the las function called? include with each visible variale the name of the function in which it was defined.

a. main calls fun1, fun1 calls fun2; fun2 calls fun3
b. main calls fun1; fun1 calls fun3
c. main calls fun2; fun2 calls fun3; fun3 calls fun1
d. main calls fun3; fun3 calls fun1
e. main calls fun1; fun1 calls fun3; fun3 calls fun2
f. main calls fun3; fun3 calls fun2; fun2 calls fun1

Thank you in advance

Last edited by shabbir; 23Jun2009 at 09:05.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Seems a trick question to me because there is an obvious answer and you might think why are they asking if it's that obvious, but what do you think the answer is dano, and why?