ProgrammingModerate

Sum of a 2 x 2 window of m[i][j] = i + j starting at (1,1) in a 4 x 4 grid, i.e. m[1][1] + m[1][2] + m[2][1] + m[2][2]. What is the value?

  1. A. 10
  2. B. 8
  3. C. 14
  4. D. 12

Correct answer: D. 12

The window holds m[1][1] = 2, m[1][2] = 3, m[2][1] = 3 and m[2][2] = 4, total 12. A topper's check: four cells symmetric around the average value 3 give 4 x 3 = 12, so 10 (one of the 3s counted as 1) is a slip.

More C Programming questions

Exams that ask this topic