The following code fragment int x, y = 2, z, a;

  • 0 replies
  • 369 views
*

Offline mechanic

  • *****
  • 2565
    • View Profile
    • Engineering Forum
The following code fragment int x, y = 2, z, a;
« on: February 26, 2017, 07:44:45 PM »
Question: The following code fragment

int x, y = 2, z, a;
x = {y *= 2} + [z = a = y};
      printf {*&d", x};

Options are:

A. prints 8
B. prints 6
C. prints 6 or 8 depending on the compiler implementation
D. is syntactically wrong

Correct answer is:

C. prints 6 or 8 depending on the compiler implementation