Question:

In C language, mat[i][j] is equivalent to: (where mat[i][j] is a two-dimensional array)

Show Hint

In C, accessing a two-dimensional array element using pointer arithmetic is done by calculating the base address and adding the appropriate offsets.
Updated On: Sep 25, 2025
  • \(\texttt{*(mat + i) + j}\)
     

  • \(\texttt{(mat + i) + j}\)
     

  • \(\texttt{((mat * i) + j)}\)
     

  • \(\texttt{*(mat + i + j)}\)
     

Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation


 

Step 1: Understand how multi-dimensional arrays work in C. 
In C, a 2D array is stored in a contiguous block of memory. To access an element at \( mat[i][j] \), you use a pointer arithmetic approach. 

- **Option 1**: \(\texttt{*(mat + i) + j}\) is the correct way to access the element at \(mat[i][j]\), because it first calculates the address of the \(i^{th}\) row and then accesses the \(j^{th}\) column element.

Step 2: Evaluate other options. 

- **Option 2**: This is not valid because \( (mat + i) + j \) is not a proper way to access the array element. 

- **Option 3**: Incorrect, as this formulation tries to use multiplication on the array, which is not valid for accessing a specific element. 

- **Option 4**: Incorrect. The formula \( *(mat + i + j) \) does not correctly access the element at row \(i\) and column \(j\).

Step 3: Conclusion. 
Thus, the correct expression is **Option 1**.

Was this answer helpful?
0
0

Questions Asked in CUET PG exam

View More Questions