S*p=&B[4];
$p$ is a pointer of type "S" which points to the element at index $4$ of some array $B$.
Similarly,
$q$ is a pointer of type "S" which points to the element at index $5$ of some array $B$.
$p$ and $q$ are neighbours. By pointer arithmetic, $q-p = 1$.
Now, union is of size $2$ Bytes. Becuase the size of a union is the size of the largest field in it. (Short = $2$ Bytes, Char = $1$ Byte)
Hence, overall struct is of size $3$ Bytes.
$2$ Bytes for Union, and $1$ Byte for the unsigned char $c$.
Given that:
/* structure S takes 32-bits */
Means, struct takes $4$ Bytes. That is because of Byte alignment. See this.
So, struct looks like this:
Union |
Char C |
Padding |
2 Bytes |
1 Byte |
1 Byte |
Because $B$ is declared as an array of $10$ elements, whose elements are of type $S$,
Hence, the overall size of array $B$ is $10*4=40$ Bytes
Suppose the starting address of the $4th$ index of $B$ is $5000$.
$p→c$ would point to $5002$
$p$ would point to $5000$.
Since both $p→c$ and $p$ are typecasted as int, and the size of an int is at least 2 Bytes, hence
$((int ) \& (p→c))–((int)p) = (5002 - 5000) / 2 = 1$
Option A is correct.