36. call by value and static scope
In main() a is assigned as 10. Now, f(10) function is called,So, f(b) copied the value of value of a in b, then b=10. Now, multiplication of b*a=10*2=20(where a takes the value of global variable a). Finally a becomes 2-20=-18. and it will update the global variable a=-18
As it is call by value, when it prints it will take value of local to main()=10
37.call by value and dynamic scope
In main() a is assigned as 10. Now, f(10) function is called,So, f(b) copied the value of value of a in b, then b=10. Now, multiplication of b*a=10*10=100(where a takes the value from where it is called , i.e. main()). Finally a becomes 10-100=-90. and it will update the global variable a=-90
But as it is dynamic scope, value of a will be updated value=-90
38.call by reference and static scope
a assigned the value of 10. f(10) is passed to b, means b also points to 10. Now, b updates to b=10*2=20. value of a updates to -18.global
And finally print 20
39.call by reference and dynamic scope
In main() a is assigned as 10. Now, f(10) function is called,So, f(b) pointed to same memory as a, the value of value of a in b, then b=10. Now, multiplication of b*a=10*10=100(where a takes the value of global variable a). global a updates to 100.
Now, a updates to a-b=0
So, 0 will be prined.