+ 2
what is myArr[0][2]=42; mean?
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4
3 Answers
+ 35
myArr [0][2] is 3 //its not 42
myArr [0][2]=42; //it means u r chaging its value from 3 to 42
myArr [0][2] mean go to 1st inside array & pickup 3rd element from it
//hope it helpsâș
+ 15
You have 2-dimensional array and the second line is making the [0][2] element be equal to 42.
MyArr before&after this action is
{ {1, 2, 3}, {4}, {5, 6, 7} };//before
{ {1, 2, 42}, {4}, {5, 6, 7} };//after
Then you are printing the [1][0], which is 4
0
1 2 3
4
5 6 7
This is the array in 2D.
The changes is going to be in the ( first row ) && ( third column )
So it will be like this:
1 2 42
4
5 6 7