Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
    a = 3;
    void n(x) {x = x * a; print(x);}
    void m(y) {a = 1; a = y – a; n(a); print(a);}
    void main() {m(a);}
    1. 6, 2
    2. 6, 6
    3. 4, 2
    4. 4, 4
Correct Option: D

Dynamic scoping refers to definition of free variable in the reverse order of calling sequence.



Your comments will be displayed only after manual approval.