Pointer p points to an array of integers where each integer has size 2 bytes.…
2023
Pointer p points to an array of integers where each integer has size 2 bytes. If p is initialized to address 200, what is the value of p + 3?
- A.
206
- B.
203
- C.
212
- D.
204
Attempted by 322 students.
Show answer & explanation
Correct answer: A
Correct answer: 206.
In C/C++, pointer arithmetic is scaled by the size of the pointed-to data type.
Here, each integer is 2 bytes. So p + 3 means move ahead by 3 × 2 = 6 bytes.
Starting address = 200, so final address = 200 + 6 = 206.