ProgrammingModerate
int grid[4][4] is filled by grid[i][j] = i * j. What is grid[3][2]?
- A. 5
- B. 12
- C. 6
- D. 9
Correct answer: C. 6
grid[3][2] holds i * j = 3 * 2 = 6; indices are 0-based, so row 3 is the fourth row. 5 adds the indices instead of multiplying, 12 treats them as 1-based (4 * 3), and 9 squares the row index.
More C Programming questions
- 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)?
- 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?