197 views

Suppose the following declarations are in effect :

1. $\text{int }a[ \: ] = \{5,15,34,54,14,2,52,72 \}$;
2. $\text{int }*p = \&a[1] , *q = \&a[5]$;

The value of  $q - p$ is ________.

sir,

here value of q-p should be 4..

if the value of *q - *p had been asked then it should be -13

@jai

q is a pointer, it store memory address of 6th element with value  2 with index 5 .

p is  another pointer, it store memory address of 2nd element  with index 1 whose value is 15.

so value for q is 5 and value for p is 1 so q-p is = 5-1 = 4

that is exactly my question

here we considering  the index position of p and q .

1
214 views