Difficulty: Easy
Correct Answer: Error
Explanation:
Introduction / Context:In C, a pointer declared as const int * is a pointer to a read-only integer. The qualifier applies to the pointed-to object as accessed through that pointer. Attempting to assign through such a pointer is forbidden and should trigger a compiler error, safeguarding program correctness by preventing unintended writes to protected data.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Determine the effective type of *ptrx → const int.Check assignment legality → writing to const object → not allowed.Compilation error occurs; the printf is never reached.Verification / Alternative check:
If ptrx were declared int * and pointed to a non-const int, *ptrx = 10 would be valid. If you tried to cast away const and still write, behavior would be undefined even if it appears to work on some platforms.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
Error
Discussion & Comments