Question 28Asked 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() { char str[20] = "Hello, World!"; printf("%s\n", str + 7); return 0; }
  1. AWorld!
  2. B, World!
  3. CCompilation error
  4. DHello, World!
Show answerHide answer

Correct answer: (A) World!

Explanation

str + 7 points to index 7 of "Hello, World!". Index 5 is ',' and 6 is the space, so printing starts at 'W' and gives "World!".

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

This is question 28 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.