Sort Matrix ISC Computer Science 2021 Practical
Write a program to declare a matrix A[][] of order (M × N) where 'M' is the number of rows and 'N' is the number of columns such that both 'M' and 'N' must be greater than 2 and less than 8. Allow the user to input integers into the matrix. Perform the following tasks on the matrix: (a) Sort the matrix elements in descending order using any standard sorting technique. (b) Calculate the sum of the boundary elements of the matrix before sorting and after sorting. (c) Display the original matrix and the sorted matrix along with the sum of their boundary elements respectively. Test your program for the following data and some random data: Example 1 INPUT: M = 3 N = 4 ENTER ELEMENTS OF MATRIX 11 2 -3 5 1 7 13 6 0 4 9 8 OUTPUT: ORIGINAL MATRIX 11 2 -3 5 1 7 13 6 0 4 9 8 SUM OF THE BOUNDARY ELEMENTS (UNSORTED) = 43 SORTED MATRIX 13 11 9 8 7 6 5 4 2 1 0 -3 SUM OF THE BOUNDARY ELEMENTS (SORTED) = 52 Example 2 INPUT: M = 3 N = 3 ENTER ELEMENTS OF MATRIX 6 2 5 14 1...