Open In App

Top | MCQs on Array Data Strcuture with Answers | Question 14

Let A be a matrix of size n x n. Consider the following program. What is the expected output? 




void fun(int A[][N])
{
    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            swap(A[i][j], A[j][i]);
}

(A)



Matrix A

(B)



Diagonal Of matrix A

(C)

Transpose of matrix A

(D)

None


Answer: (C)
Explanation:

In the above program, we are just swapping(arr[i][j]) to arr[j][i]). That means row will become column and column will become row.
That means the Transpose of the graph.

 

Hence (C) is the correct output.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :
Uncategorized