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

What is the output of the following code? #include <stdio.h>

What is the output of the following code? #include <stdio.h> void func(int *p) { int q = 10; p = &q; } int main() { int x = 20, *ptr = &x; func(ptr); printf("%d\n", *ptr); return 0; }
  1. ACompile time error
  2. B20
  3. C10
  4. DGarbage value
Show answerHide answer

Correct answer: (B) 20

Explanation

C passes the pointer by value, so p = &q changes only the local copy in func. ptr still points to x, and 20 is printed.

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

This is question 25 of DSSSB TGT Computer Science PYQ (Technical), 13 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.