Difficulty: Easy
Correct Answer: j is a pointer to an int and stores address of i
Explanation:
Introduction / Context:
This straightforward question confirms understanding of a pointer declaration and initialization in C. It asks you to identify which variable is a pointer and what address it holds.
Given Data / Assumptions:
Concept / Approach:
In C, a declaration of the form int *j means j is a pointer to an int. The ampersand operator & yields the address of its operand. Thus, &i is the address of i, and assigning that to j makes j point to i.
Step-by-Step Solution:
i is a plain integer with value 10.j is declared with a star, so it is a pointer to int.j is initialized with &i, meaning j stores the address where i lives.Therefore, *j would yield the value 10 if dereferenced later.
Verification / Alternative check:
Adding printf statements like printf("%d", *j); would print 10, demonstrating that j indeed points to i. Printing j with %p would show a nonzero address value.
Why Other Options Are Wrong:
i is not a pointer; it is an int. j is not a pointer to a pointer (that would be int *j;). Claiming both are pointers or both are identical integers is incorrect.
Common Pitfalls:
Misplacing the star (e.g., int j, int *j—stylistic spacing does not change meaning); confusing the value stored in i with the address stored in j.
Final Answer:
j is a pointer to an int and stores address of i
Discussion & Comments