0

Can anybody explain me why the following part of code produces the result 21? Here is the code:

int a[2][4]={3,6,9,12,15,18,21,24};
cout << 2[1[a]];

Thanks in advance!

MikeCAT
  • 73,922
  • 11
  • 45
  • 70
gdaras
  • 9,401
  • 2
  • 23
  • 39
  • Using the dupe's answer, `2[1[a]]` is `*(2 + *(1+a))`. Then `*(1+a)` is `a[1]`, which is the second set of four elements. Applying the same logic to the outer part gives us the third element of that second set. – chris Aug 06 '16 at 15:46
  • Great explanation! Thanks :) – gdaras Aug 06 '16 at 15:58

0 Answers0