Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (20 points) Consider the following skeletal C program: void fun1(void)

ID: 3725793 • Letter: P

Question

Problem 4 (20 points) Consider the following skeletal C program: void fun1(void);/* prototype/ void fun2(void);/* prototype / void fun3(void);/* prototype/ void main() f int a, b, c; void fun1(void) int b, c, d; void fun2(void) f int c, d, e void fun3(void) int d, e, f; Given the following calling sequences and assuming that dynamic scoping is used, what va are visible during execution of the last function called? Include with each visible variable the m of the function in which it was defined. riables ame 1. main calls fun1; fun1 calls fun2; fun2 calls fun3. 2. main calls fun1; fun1 calls fun3. 3. main calls fun2; fun2 calls fun3; fun3 calls fun1 4. main calls fun3; fun3 calls fun1. 5. main calls fun1; fun1 calls fun3; fun3 calls fun2.

Explanation / Answer

In dynamic scoping, scoping is defined as per calling sequence.

1. fun3 is last

   f is defined in fun3
   e is define in fun3
   d is defined in fun3

   c is visible from fun2
   b is visible from fun1
   a is visible form main


2. fun3 is last

   f is defined in fun3
   e is define in fun3
   d is defined in fun3

   c and b are visible from fun1
   a is visible from main

3. fun1 is last

b is defined in fun1
c is define in fun1
d is defined in fun1

   e and f are visible from fun3
   a is visible from main


4. fun1 is last

b is defined in fun1
c is define in fun1
d is defined in fun1

   e and f are visible from fun3
   a is visible from main

5. fun2 is last

c is defined in fun2
d is define in fun2
e is defined in fun2  

f is visible from fun3
b is visible from fun1
a is visible from main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote