Question 25Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)

What will be the output of the following code? int main() {

What will be the output of the following code? #include<stdio.h> int main() { int x=5,y; y=x++ + ++x; printf("%d",y); return 0; }
  1. A11
  2. Bcompile time error
  3. C12
  4. D10
Show answerHide answer

Correct answer: (C) 12

Explanation

x++ gives 5 (x becomes 6), then ++x makes x 7, so y = 5 + 7 = 12 on common compilers. Strictly, modifying x twice in one expression is undefined behaviour in C.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 3 (5:00 PM)

This is question 25 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 3 (5:00 PM). 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.