Consider a program is accessing an array location A[i][j]. The following…

Consider a program is accessing an array location A[i][j]. The following intermediate code is generated by the compiler.
t1 = i * 16
t2 = j * 4
t3 = t1 + t2
t4 = A[t3]
Assuming that the size of an integer is 4 Bytes and size of an element is 1 Byte.
Which of the following statement is Correct?

Answer: C. A is declared as int A[3][4]Key insight: deduce element size and number of columns from the multipliers in the intermediate code. From t2 = j * 4: each element occupies 4 bytes, so the…

  1. A.

    A is declared as int A[4][3]

  2. B.

    A is declared as char A[4][3]

  3. C.

    A is declared as int A[3][4]

  4. D.

    A is declared as char A[3][4]

Attempted by 56 students.

Show answer & explanation

Correct answer: C

Key insight: deduce element size and number of columns from the multipliers in the intermediate code.

  • From t2 = j * 4: each element occupies 4 bytes, so the element type is int (4 bytes).

  • From t1 = i * 16: the row offset is i * (number_of_columns * element_size) = i * (C * 4) = i * 16, so C * 4 = 16 → C = 4 columns.

  • Therefore the addressing expression corresponds to an int array with 4 columns. The declaration int A[3][4] matches the inferred element size and column count. (The number of rows cannot be determined from these multipliers alone, but the given option with 3 rows is consistent.)

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…