Question 95Asked in DSSSB PGT Computer Science (Technical), 11 Jul 2021

What is the output of code? void main ()

What is the output of code? void main () { int x = 33, y, z; z = x++ + 17; y = ++z − ++x; cout << "x" << x << "y" << y << "z" << z; }
  1. Ax = 34 y = 17 z = 51
  2. Bx = 35 y = 16 z = 51
  3. Cx = 34 y = 16 z = 50
  4. Dx = 35 y = 17 z = 51
Show answerHide answer

Correct answer: (B) x = 35 y = 16 z = 51

Explanation

z = x++ + 17 = 33 + 17 = 50 and x becomes 34. y = ++z − ++x = 51 − 35 = 16. So x = 35, y = 16, z = 51.

From DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021

This is question 95 of DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.