2D Array Practice Questions
2D Array Practice Questions
char a[100][100];
Assuming that the main memory is byte-addressable and that the array is stored starting from
memory address 0. Find the address of a[40][50] using row and column major.
21. Let A be a square matrix of size n x n. Consider the following program. What is the expected
output?
C = 100;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
Temp = A[i][j] + C;
A[i][j] = A[j][i];
A[j][i] = Temp – C;
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
printf(“%d ”,A[i][j]);