Question: A square matrix has 2 different diagonal lines. One of them starts from the top left and continues until bottom right. It is called a
A square matrix has 2 different diagonal lines. One of them starts from the top left and continues until bottom right. It is called a major diagonal line. The second one starts from top right and continues until the bottom left. This is called a minor diagonal line. abo aor ao2 a 10 ali a12 a 20 a 21 aza Minor Diagonal Line Major Diagonal Line Fig-1 3x3 Square Matrix with Diagonal Lines To change the values in diagonal lines, each corresponding element on the same row of the matrix should be swapped. For example in Fig-2.a, if the diagonal lines in the matrix are swapped, we get the resultant matrix that is given in Fig-2.b. 1 2 3 4 42 3 1 5 6 7 8 5 Z 6 8 9 10 11 12 9 11 10 12 13 14 15 16 16 14 15 13 Fig-2.a 4x4 Matrix before changing Fig-2.b 4x4 Matrix after swapping Write a C program that creates a square matrix with randomly generated values in the range 1-5,5). The height or width (size) of this matrix will be taken from the user. If the user enters value N as size, you will create an NxN array with random values. N can be a maximum of 10. After creating the array, you must show the matrix to the user and matrix elements must be aligned. In the end, you must display the resultant matrix in which diagonals have been swapped
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
