2 2 votes Consider the following code given below int A[8][8], p, q; for(p = 0; p < 8; ++p) for(q = 0; q < 8; q++) { A[p][q] = A[q][p]; } What will happen to matrix A ? Programming in C + – Rohan Mundhey 1.4k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply Prabhanjan_1 commented Oct 2, 2016 reply Follow flag if 2d array is represented as matrix then transpose of matrix is the answer ... 0 0 replyShare vijaycs commented Oct 2, 2016 i edited by vijaycs Oct 2, 2016 reply Follow flag Thanks @ManojK, My bad, lets take an example- A= 1 2 3 4 5 6 7 8 9 and after execution it has become - 1 4 7 4 5 6 7 6 9 4 4 replyShare vijaycs commented Oct 2, 2016 i edited by vijaycs Oct 2, 2016 reply Follow flag ....... 0 0 replyShare ManojK commented Oct 2, 2016 reply Follow flag A will become symmetric matrix. 1 1 replyShare ManojK commented Oct 2, 2016 reply Follow flag Now fine. 0 0 replyShare ManojK commented Oct 2, 2016 reply Follow flag (1)For transpose take a new array .Copy the element. B[j][i]=a[i][j]; (2) If you want make change in same array. Simply reverse the loop 0 0 replyShare vijaycs commented Oct 2, 2016 reply Follow flag If it was a swap operation between A[p][q] and A[q][p], then we would have got the same A. And if it was swap + 2nd for loop = for(q=p ; q< 8 ; q++) then it would have transpose of A. @ManojK , now check.. 0 0 replyShare ManojK commented Oct 2, 2016 reply Follow flag Not getting copy and edit the code here . 0 0 replyShare Please log in or register to add a comment.
1 1 vote it convert A into symmetric matrix try on 3 x 3 matrix Shubham Pandey 2 answered Oct 2, 2016 Shubham Pandey 2 comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes symmetric matrix p=0 for(q = 0; q < 8; q++) replace 1st row with 1st column p=1 for(q = 0; q < 8; q++) replace 2nd row with 2nd column and so on try with 3*3 matrix Anil Khatri answered Oct 2, 2016 Anil Khatri comment Share Follow 0 reply Please log in or register to add a comment.