Multiple choice technology programming languages

Determine Output: int main() { int a[5] = {1,2,3,4,5}; int ptr = (int)(&a+1); printf("%d %d" , *(a+1), *(ptr-1) ); return 0; }

  1. 2,1

  2. 2,5

  3. compile error

  4. 2,2

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

*(a+1) accesses the second element (index 1) = 2. (&a+1) points past the entire array, so ptr-1 points to the last element = 5. Output is '2 5'.