void fun1(void) ;     
void fun2(void) ;
void fun3(void) ;
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 ;

      ...

}


  • #5-14 page 248
    Given the following calling sequences and assuming that dynamic scoping is used, 
    what variables are visible during execution of the last subprogram activated?
    Include with each variable the name of the unit where it was defined.
    
    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.
    6. Main calls Sub3; Sub3 calls Sub2; Sub2 calls Sub1.


    procedure Main is
    
        X, Y, Z : Integer;
    
        procedure Sub1 is
    
           A, Y, Z : Integer;
    
           begin  -- of Sub1
    
            ...
    
           end   -- of Sub1
    
        procedure Sub2 is 
    
           A, B , Z : Integer ;
    
           begin   -- of Sub2
    
           ...
    
           end   -- of Sub2
    
         procedure Sub3 is
    
            A, X, W : Integer ;
    
            begin    --- of Sub3
    
            ...
    
    
             end    ---  of Sub3
    
        begin    --- of Main
    
        ...
    
        end  -- of Main