Computer Science EngineeringVery hardISRO SC

Global int g = 2; procedure P(a, b) { a = a + 5; b = b + a; print(a + b + g); } is called as P(g, g). The value printed under call by value-result (copy in, copy out left to right: a then b; the print happens before copy-out) is

  1. A. 42
  2. B. 18
  3. C. 21
  4. D. 23

Correct answer: B. 18

Copy-in: a=b=g=2. a=7; b=2+7=9; g still 2 at the print: 7+9+2.

More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions

Exams that ask this topic