Difficulty: Easy
Correct Answer: Error: Lvalue required/incompatible types in assignment
Explanation:
Introduction / Context:
In C, arrays are not assignable after declaration. Initializing a char array with a string literal is allowed at declaration time, but assigning a string literal to an existing array variable is not permitted. This question checks that rule within a struct context.
Given Data / Assumptions:
Concept / Approach:
Array identifiers decay to pointers in expressions but arrays themselves cannot be assigned to. To copy text into a char array, use library functions such as strcpy or strncpy, or read into it via scanf/gets (unsafe)/fgets with care.
Step-by-Step Solution:
Verification / Alternative check:
Replacing the assignment with strcpy or an initializer compiles and runs, printing "Suresh 25".
Why Other Options Are Wrong:
Common Pitfalls:
Confusing array assignment with pointer assignment. A char * can be assigned to point to a literal; a char[] cannot be assigned after declaration.
Final Answer:
Error: Lvalue required/incompatible types in assignment
Discussion & Comments