Complete the code to declare a 2D array of integers with 3 rows and 4 columns.
int arr[3][[1]];
The second dimension size is the number of columns, which is 4 here.
Complete the code to access the element in the second row and third column of a 2D array named 'matrix'.
int value = matrix[[1]][2];
Array indices start at 0, so the second row is index 1.
Fix the error in the code to correctly initialize a 2D array with 2 rows and 3 columns.
int grid[2][3] = {{ {1, 2, 3}, [1] }};
Each row must be enclosed in braces {}. So the second row is {4, 5, 6}.
Fill both blanks to declare and initialize a 2D array named 'table' with 2 rows and 2 columns, containing values 1, 2, 3, 4.
int table[[1]][[2]] = {{ {1, 2}, {3, 4} }};
The array has 2 rows and 2 columns, so both dimensions are 2.
Fill all three blanks to create a nested loop that prints all elements of a 2D array 'data' with 3 rows and 2 columns.
for (int i = 0; i < [1]; i++) { for (int j = 0; j < [2]; j++) { std::cout << data[i][j] << [3]; } std::cout << std::endl; }
The outer loop runs 3 times for rows, inner loop 2 times for columns, and elements are separated by a space.