Question: Square matrix : In mathematics, a square matrix is a matrix with the same number of rows and columns. An n-by-n matrix is known as

Square matrix : In mathematics, a square matrix is a matrix with the same number of rows and columns. An n-by-n matrix is known as a square matrix of order n. Distinct Matrix: A matrix is called a distinct matrix if it contains unique elements/values; no duplicates. Such that of one cell contains the value x then no other cell in the matrix contains this value x

Magic Square: In recreational mathematics and combinatorial design, a magic square is a square matrix filled with distinct positive integers and the sum of the integers in each row, column and diagonal is equal. The sum is called the magic constant or magic sum of the magic square. A square grid with n cells on each side is said to have order n.

Not every magic square is a distinct matrix but not every distinct matrix is a magic square

2 7 6
9 5 1
4 3

8

Magic Square With magic sum = 15 Distinct Matrix

5 -1 9 1
2 6 9 1
1 4 8 8
1 7 5 -4

Not a magic square or distinct It contains negative numbers, duplicates

5 2 7
8 1 10
4 3 9

Not magic square but a distinct matrix

A row-wise sorting for a matrix is to short each row in the input matrix in ascending order, for example, given the following

5 -1 9 1
2 6 9 1
1 4 8 8
1 7 5 -1

The output will be the following a row-wise sorted matrix

-1 1 5 9
1 2 6 9
1 4 8 8
-4 1 5 7

Given a square matrix, the transpose of the matrix is a new matrix whose rows are the columns of the original. (This makes the columns of the new matrix the rows of the original). Here is a matrix and its transpose.

3 7 -1
5 8 -5
1 9 -6

Original Matrix

3 5 1
7 8 9
-1 -5 -6

Transpose Matrix

Requirements

Use the code skeleton on the next page to write a C program that allows the user to create any square matrix (a 2D arrays with the same number of rows and columns), for instance, a square matrix of size 5 is a 2d array of 5 rows and 5 columns. main program should:

1. Allow the user to set the size (order) of the square matrix

2. Set the values of the matrix

3. Print the square matrix on the screen in a tabular format

4. Check and print if the square matrix is a magic square or not.

5. Check and print if the square matrix is a distinct matrix or not.

6. Sort the square matrix using row-wise approach.

7.Calculate the transpose matrix for the square matrix

need the description to the function of each line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!