Computer Science EngineeringVery hard

For void f(int x, int y){ x = x + 1; y = y + x; } with int a = 1, b = 2; calling f(a, b) by reference, what are the values of a and b afterwards?

  1. A. a=1, b=2
  2. B. a=2, b=3
  3. C. a=2, b=4
  4. D. a=3, b=4

Correct answer: C. a=2, b=4

x aliases a so a becomes 2, and y aliases b so b becomes 2 + 2 = 4.

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

Exams that ask this topic