Multiple choice technology programming languages

void main() { int i = 10; int *p=&i; p++; printf("%d",(p-&i)); }

  1. 0

  2. 1

  3. compile error

  4. 10

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Pointer p is assigned address of i. Then p++ increments p by one integer (4 bytes on most systems). The expression (p - &i) calculates the offset between the new pointer address and original address, which is 1 integer - not 1 byte. The difference is measured in the pointer's data type units, so it equals 1.