The statement int num[2][3] = {{1,2}, {3,4}, {5, 6}};

”assigns
[2]” option2=”assigns a value 4 to num[1][2]” option3=”gives an error message” option4=”assigns a value 3 to num[1][2]” correct=”option1″]

The correct answer is: A. assigns a value 2 to num[1][2].

The statement int num[2][3] = {{1,2}, {3,4}, {5, 6}}; creates a 2×3 array, which means it has 2 rows and 3 columns. The first row is assigned the values {1,2}, the second row is assigned the values {3,4}, and the third row is assigned the values {5,6}.

When we access an element in an array, we use the index of the row and the index of the column. The index of the row starts at 0, and the index of the column starts at 0. So, num[1][2] refers to the element in the second row and the second column, which is the value 2.

Option B is incorrect because the value 4 is in the third column, not the second column. Option C is incorrect because the statement does not give an error message. Option D is incorrect because the value 3 is in the first column, not the second column.

Exit mobile version