GATE Computer ScienceEasyGATE CS (PYQ pattern)

int a[3][4] = {{3,1,4,1},{5,9,2,6},{5,3,5,8}}; int t = 0; for (int j = 0; j < 4; j++) for (int i = 0; i < 3; i++) t += *(*(a + i) + j) * (j + 1) * (i % 2 + 1); What is t?

  1. A. 175
  2. B. 185
  3. C. 197
  4. D. 52

Correct answer: B. 185

Weight each element by (column + 1) and by 2 for the middle row (1 for rows 0 and 2): the sum is 185.

More Programming and Data Structures (GATE) questions

Exams that ask this topic