GATE CS 2015, set 3 · Question 11 · Programming and Data Structures · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Consider the following C program segment.
#include <stdio.h> int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); }
What will be printed by the program?

  1. (A) 12
  2. (B) 120400
  3. (C) 1204
  4. (D) 1034
Answer

Answer (C)

Answer from the official GATE CS 2015 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes