Question: Document the arrays, using a chart with columns titled:outer loop, inner loop, i, j, and x. Finally, draw a picture of each array (after the
Document the arrays, using a chart with columns titled:outer loop, inner loop, i, j, and x. Finally, draw a picture of each array (after the program portion has executed).
int[][] arr1 = new int[5][5];
int[][] arr2 = new int[5][5];
x = 1;
for(int i = 0; I < 5; i++) {
for(int j = 1; j < 6; j++) { arr1[i][j-1] = x;
x++;
if(x == 6)
x += 2;
}
}
for(int i = 4; i >= 0; i--)
for(int j = 4; j > -1; j--) arr2[j][i] = arr1[i][j];
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
