Author Topic: The following code fragment int x, y = 2, z, a;  (Read 397 times)

Offline mechanic

The following code fragment int x, y = 2, z, a;
« on: February 26, 2017, 07:44:45 PM »
Advertisement
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


Engineering Forum

The following code fragment int x, y = 2, z, a;
« on: February 26, 2017, 07:44:45 PM »