Question 27Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 1 (9:00 AM)

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 = -1, y = 0, z = 1; int result = (x > 0) ? x : (y == 0) ? z : y; printf("%d", result); return 0; }
  1. Acompile time error
  2. B−1
  3. C1
  4. D0
Show answerHide answer

Correct answer: (C) 1

Explanation

x > 0 is false, so the second conditional (y == 0) ? z : y is evaluated. y is 0, so the result is z = 1.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 1 (9:00 AM)

This is question 27 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 1 (9:00 AM). 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.