ProgrammingModerate
For the grid [[1, 2, 3], [4, 5, 6]], what is the sum of the column 2 values (the third column, 0-based index 2)?
- A. 5
- B. 7
- C. 8
- D. 9
Correct answer: D. 9
Column index 2 is the third column: row 0 gives 3 and row 1 gives 6, so the sum is 9. 7 uses column 1 (2 + 5) and 5 uses column 0 (1 + 4), both 0-based slips.
More C Programming questions
- In row-major order, the cell a[i][j] of a matrix with C columns sits at which flat index?
- A matrix multiplication of a 3 x 4 matrix by a 4 x 2 matrix produces a result of what size?
- How many scalar multiplications does the naive method use for a 3 x 4 times 4 x 2 product?
- A tic-tac-toe board stored as char b[3][3] is full. What is the minimum number of moves that could have been made on it?
- The function void zero(int n, int m[][n]) assigns zero to all cells. Which loop is correct for n x n data?
- A 2D array is stored in memory and read in column-major order by mistake in a C program. What is the main consequence?