Gate CS-2014-3 Question Paper With Solutions

Q. 20 Let A be a square matrix of size n#n. Consider the following pseudocode. What
is the expected output?

C = 100
for i = 1 to n do
    for j = 1 to n do
    {
        Temp = A[i][j] + C
        A[i][j] = A[j][i]
        A[j][i] = Temp - C
    
for i = 1 to n do
    for j = 1 to n do
        Output(A[i][j]);

(A) The matrix A itself

(B) Transpose of the matrix A

(C) Adding 100 to the upper diagonal elements and subtracting 100 from lower
diagonal elements of A

(D) None of the above

Answer: (A)

Explanation:

Gate CS-2014-3 Question Paper With Solutions

Learn More:   Gate ME 2015-1 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here