Register
 

Engrz Upload (Upload and Share Your Files)

Engineering Education Forum



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

Online mechanic

  • Engineer
  • Hero Engineer
  • *****
  • Posts: 3125
    • View Profile
    • Engineering Forum
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 Education Forum

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