Which one of the following will declare a pointer to an integer at address…
2015
Which one of the following will declare a pointer to an integer at address 0x200 in memory?
- A.
int *x;
*x = 0x200; - B.
int *x = &0x200;
- C.
int *x = *0x200;
- D.
int *x = 0x200;
- E.
Question not attempted
Attempted by 408 students.
Show answer & explanation
Correct answer: D
To declare a pointer to an integer at address 0x200, the pointer variable must be initialized with the address value directly. Option A: int * x; *x = 0x200; declares a pointer but does not assign the address. The second line attempts to write to the memory location pointed to by x, which is undefined since x is not initialized. Option B: int *x = &0x200; uses the address-of operator (&) on a literal address, which is invalid. The & operator requires a variable name, not a constant value. Option C: int * x = * 0x200; uses the dereference operator (*) on a literal address, which is invalid. The * operator requires a pointer variable, not a constant. Option D: int *x = 0x200; correctly assigns the address 0x200 to the pointer variable x. This initializes the pointer to point to the specified memory location.