KINDLY READ THE QUESTION CAREFULLY AND DON'T USE ANY SQUARE BRACKETS IN YOUR CODE . AND OUTPUT MUST MATCH AS IT IS . ----------------------------- Write a program to find the type of square matrix using functions. a) Function - findSymmetric which returns 1 if the matrix is symmetric and 0 if the matrix is not symmetric. If the transpose of a matrix is equal to itself, that matrix is said to be symmetric. b) Function - findIdentity which returns 1 if the matrix is an identity matrix and 0 if the matrix is not an identity matrix. An Identity matrix is a square matrix in which 1s on the main diagonal, and 0s everywhere else. c) Function - findMagic which returns 1 if the matrix is a magic square and 0 if the matrix is not a magic square. A Magic Square is a square matrix in which the sum of the elements in each row and column is the same. Note: Use dynamic allocation of memory. (i.e use malloc()). Use functions for reading and displaying a matrix and to find the matrix types. Function specification: int ** readMatrix(int rows, int cols) void displayMatrix(int** a,int rows, int cols) int findSymmetric(int ** a, int n). int findIdentity(int ** a, int n) int findMagic(int ** a, int n) Input Format: Input consists of (n*n)+1 integers. The first integer corresponds to n, the number of rows/columns in the matrix. The next 'n' integers correspond to the elements in the first row of the matrix. The next 'n' integers correspond to the elements in the second row of the matrix and so on. Output Format: Refer to Sample Output for formatting details. [All text in bold corresponds to input and the rest corresponds to output.] Sample Input and Output 1: Enter the number of rows and columns in the matrix 3 Enter the elements in the matrix 1 0 0 0 1 0 0 0 1 The given matrix is 1 0 0 0 1 0 0 0 1 Matrix is Symmetric Matrix is Identity Matrix is Magic Sample Input and Output 2: Enter the number of rows and columns in the matrix 3 Enter the elements in the matrix 23 45 23 13 34 56 78 45 34 The given matrix is 23 45 23 13 34 56 78 45 34 Matrix is not Symmetric Matrix is not Identity Matrix is not Magic Problem Requirements: C Keyword Min Count Max Count ] 0 0 Keyword Min Count Max Count [ 0 0 Function Definitions: int ** readMatrix (int , int) void displayMatrix (int **, int, int) int findSymmetric (int **, int) int findIdentity (int **,int) int findMagic (int **, int)
KINDLY READ THE QUESTION CAREFULLY AND DON'T USE ANY SQUARE BRACKETS IN YOUR CODE . AND OUTPUT MUST MATCH AS IT IS .
-----------------------------
Write a program to find the type of square matrix using functions.
a) Function - findSymmetric which returns 1 if the matrix is symmetric and 0 if the matrix is not symmetric. If the transpose of a matrix is equal to itself, that matrix is said to be symmetric.
b) Function - findIdentity which returns 1 if the matrix is an identity matrix and 0 if the matrix is not an identity matrix. An Identity matrix is a square matrix in which 1s on the main diagonal, and 0s everywhere else.
c) Function - findMagic which returns 1 if the matrix is a magic square and 0 if the matrix is not a magic square. A Magic Square is a square matrix in which the sum of the elements in each row and column is the same.
Note:
Use dynamic allocation of memory. (i.e use malloc()).
Use functions for reading and displaying a matrix and to find the matrix types.
Function specification:
int ** readMatrix(int rows, int cols) |
void displayMatrix(int** a,int rows, int cols) |
int findSymmetric(int ** a, int n). |
int findIdentity(int ** a, int n) |
int findMagic(int ** a, int n) |
Input Format:
Input consists of (n*n)+1 integers.
The first integer corresponds to n, the number of rows/columns in the matrix.
The next 'n' integers correspond to the elements in the first row of the matrix.
The next 'n' integers correspond to the elements in the second row of the matrix and so on.
Output Format:
Refer to Sample Output for formatting details.
[All text in bold corresponds to input and the rest corresponds to output.]
Sample Input and Output 1:
Enter the number of rows and columns in the matrix
3
Enter the elements in the matrix
1 0 0
0 1 0
0 0 1
The given matrix is
1 0 0
0 1 0
0 0 1
Matrix is Symmetric
Matrix is Identity
Matrix is Magic
Sample Input and Output 2:
Enter the number of rows and columns in the matrix
3
Enter the elements in the matrix
23 45 23
13 34 56
78 45 34
The given matrix is
23 45 23
13 34 56
78 45 34
Matrix is not Symmetric
Matrix is not Identity
Matrix is not Magic
Problem Requirements:
C
Keyword | Min Count | Max Count |
] | 0 | 0 |
Keyword | Min Count | Max Count |
[ | 0 | 0 |
Function Definitions:
int ** readMatrix (int , int) |
void displayMatrix (int **, int, int) |
int findSymmetric (int **, int) |
int findIdentity (int **,int) |
int findMagic (int **, int) |
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images