Difficulty: Easy
Correct Answer: Error
Explanation:
Introduction / Context:
This focuses on the difference between a modifiable char array and the immutability of an array name as an lvalue. While you may modify the contents of a char array element by element, you cannot reassign the array variable itself to point to a different string literal after declaration.
Given Data / Assumptions:
Concept / Approach:
In C, an array variable is not a pointer variable that you can reassign; it represents a fixed block of memory. You may copy into it with functions like strcpy, but assigning a new literal to the array variable is a compile-time error.
Step-by-Step Solution:
Verification / Alternative check:
If you replace the invalid assignment with strcpy(str, 'Kanpur'); then the final print could show 'anpur' from str+1.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing arrays with pointers; trying to reassign arrays instead of copying data into them.
Final Answer:
Error.
Discussion & Comments