ISRO Computer Science (CSE) 2014 - Question 47

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 2014

The following three 'C' language statements is equivalent to which single statements?\n```c\ny = y + 1;\nz = x + y;\nx = x + 1;\n```

  • A. z = x + y + 2;
  • B. z = (x++) + (++y);
  • C. z = (++x) + (y++);
  • D. z = (x++) + (++y) + 1;

Answer: B. z = (x++) + (++y);

Explanation: `++y` increments y then uses it (matches `y=y+1` before `z=...`).\n`x++` uses x then increments it (matches `z=x+y` using old x, then `x=x+1`).\nSo `z = x + (y+1)` with side effects.

| | All questions of ISRO Computer Science (CSE) 2014