Difficulty: Easy
Correct Answer:
Explanation:
Introduction / Context:
Pointers store memory addresses, and dereferencing a pointer accesses the object at that address. This is central to dynamic memory, arrays, and function parameters. Knowing the distinct roles of the unary * and & operators avoids confusion when reading and writing pointer code.
Given Data / Assumptions:
Concept / Approach:
The unary * operator is the dereference operator. Applied to a pointer p, the expression *p yields the lvalue of the object pointed to. Conversely, & is the address-of operator that produces a pointer from an object. The tokens && and || are logical operators for boolean conditions and have nothing to do with pointer access.
Step-by-Step Solution:
Given int x = 10; int *p = &x; the expression *p evaluates to 10.Assignments through pointers use dereference: *p = 42; changes x to 42.Therefore, the operator that “gets the value at the address” in a pointer is *.
Verification / Alternative check:
Print *p and x after assignments to confirm they remain in sync because they refer to the same object via direct and indirect access.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing * in declarations (type name) with * in expressions (dereference); both are related but occur in different grammatical contexts.
Final Answer:
.
Discussion & Comments