Question 9Asked in DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3

What is the output of the code written in C? void main()

What is the output of the code written in C? void main() { int k, v; k = (v=20, v+2); printf("%d/n", k); }
  1. A2
  2. B20
  3. C22
  4. DError
Show answerHide answer

Correct answer: (C) 22

Explanation

The comma operator evaluates v = 20, then v + 2, and returns the last value, so k = 22. (The "/n" is printed literally after it.)

From DSSSB TGT Computer Science PYQ (Technical), 7 Aug 2021, Shift 3

This is question 9 of DSSSB TGT Computer Science PYQ (Technical), 7 Aug 2021, Shift 3. 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.