I am executing this code, but i am not able to get why the 6th part is showing answer 2 instead of 1.
#include<stdio.h>
int main()
{
int x[3][5] = {
{1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15}
};
int *n = (int *)&x;
printf("1) %d\n2) %d\n3) %d\n4) %d\n5) %d", *(*(x+2)+1), *(*x + 2)+5, *(*(x+1)), *(*x +2)+1, *(*(x+1) +3) );
printf("\n6) %d\n7) %d\n8) %d\n9) %d\n10) %d\n", *(n+0), *(n+2), (*(n+3) + 1), *(n+5) +1, ++*n);
}
Output of the code is :
1) 12
2) 8
3) 6
4) 4
5) 9
6) 2 // i am not getting this.
7) 3
8) 5
9) 7
10) 2
According to me the answer of part 6th must be 1. Why this is so?