Multiple choice technology programming languages

What will be the output of the following: void main() { char const *ptr="abc"; ptr="xyz"; printf("%s",ptr); }

  1. None of these

  2. Compile time error

  3. abc

  4. xyz

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

const char *ptr means the data is const (can't change what ptr points to), but ptr itself can be reassigned. ptr = xyz works because we're changing where ptr points, not modifying abc. Output: xyz.