Last Updated : 17 Dec, 2018

What will be the output of the C program given below?

 #include  
#define n 3
void matrix(int A[n][n], int B[n][n]) 
{ 
    int i, j; 
    for (i = 0; i < n; i++) 
        for (j = 0; j < n; j++) 
            B[i][j] = A[j][i]; 
} 
int main() 
{ 
    int A[3][3]={{1,2,3},{1,2,3},{1,2,3}}; 
   int B[3][3], i, j; 
   matrix(A, B); 
   printf(\"Result matrix is \\n\"); 
    for (i = 0; i < n; i++) 
    { 
        for (j = 0; j < n; j++) 
           printf(\"%d \", B[i][j]); 
        printf(\"\\n\"); 
    } 
  
    return 0; 
}

(A) matrix A

(B) transpose of the matrix A
(C) change the columns of matrix A

(D) change the rows of matrix A


Answer: (B)

Explanation:

Quiz of this Question


Share your thoughts in the comments