+ 1
Can someone help me with these type of problems
What is the output of this code? int a[3][4] = {{4,8,13,9},{1,6,9,3}, {0,2,7,10}}; cout << *(*(a+1)+2);
5 Answers
+ 4
The a is the address of the array, so that is where the first element a[0][0] is found. When we do a+1 we step to the address at the beginning of the next row of the array, the {1,6,9,3} , then the +2 shifts to the right by 2 elements, which is the 9 which is the element at a[1][2]. The * denotes that we want the value stored in that address. I hope that helps.
+ 4
Yash Shetty
in 1D array
int a[]={1,2,3,4};
a+1 is &a[1]
*(a+1) is a[1]
2D array is an 1D array of arrays
so in your code
*(a+1) will give {1,6,9,3}
let b is *(a+1) /*in your mind*/
*(b+2) is the 3rd element of {1,6,9,3}
which is 9
+ 3
it is the same with a[1][2]
so the answer is 9
0
Sorry but can you please elaborate!
0
Thanks for the help!