0
Why are we incrementing a variable k in a two dimensional array l
like int a[][]=new int[4][5]; int i,j, k=0; for(i =0;i <4; i++) for(j=0;j<5;j++){ a [i ][j]=k; k++;}
4 Answers
+ 2
All array values are 0. After that k becomes 1. k++ is outside of both loops.
+ 1
Now I see brackets, which combine array value asignment and incrementing of k. That fills array as {{0,1,2,3,4},{5,6,7,8,9} ... etc
+ 1
"we are storing value of a[I][j] in k" - oh, no. We are storing the value of k in a[i][j].
0
we are storing value of a[I][j] in k but why are we incrementing k