0

int a = 2;
void f(int b){
b = b*a;
a = a-b;
}

void main(){
int a = 10;
f(a);
print a;
}

a) Call-By-Value and Lexical Scoping
b) Call-By-Value and Dynamic Scoping
c) Call-By-Reference and Lexical Scoping
d) Call-By-Reference and Dynamic Scoping

My answer :
a) 10
b) 10
c) 20
d) 100

Please suggest me if i am doing something wrong ?

lifeisshubh
  • 513
  • 1
  • 5
  • 27
  • In second part, does the value of a will be affected to because of dynamic scoping. Value of a in function at the end will be -90. Does, it can affect the value of original a in main function scope ? – lifeisshubh Jan 06 '17 at 06:12
  • Slight correction. answers will be 10, -90, 20, 0. Plz refer example of [dynamic scoping](http://www.gatementor.com/viewtopic.php?f=264&t=10106&start=0) – sameerkn Jan 06 '17 at 07:51

0 Answers0