Question 13Asked in UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)

What will be the output of the following 'C' code? main ( )

What will be the output of the following 'C' code? main ( ) { int x = 128 ; printf("\n%d", 1 + x++); }
  1. A128
  2. B129
  3. C130
  4. D131
Show answerHide answer

Correct answer: (B) 129

Explanation

x++ is a post-increment, so the old value 128 is used in the expression and printf prints 1 + 128 = 129; x becomes 129 only afterwards.

From UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions)

This is question 13 of UGC NET Computer Science PYQ, December 2014 (Paper II & III, Selected Questions). 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.