- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C Program To Check whether Matrix is Skew Symmetric or not?

Square Matrix A is said to be skew-symmetric if aij=−aji for all i and j. In other words, we can say that matrix A is said to be skew-symmetric if transpose of matrix A is equal to negative of Matrix A i.e (A^{T}=−A).

Note that all the main diagonal elements in the skew-symmetric matrix are zero.

lets take an example of a matrix

A= |0 -5 4| |5 0 -1| |-4 1 0|

It is skew-symmetric matrix because aij=−aji for all i and j. Example, a12 = -5 and a21=5 which means a12=−a21. Similarly, this condition holds true for all other values of i and j.

We can also verify that Transpose of Matrix A is equal to negative of matrix A i.e A^{T}=−A.

A^{T}= |0 5 -4| |-5 0 1| |4 -1 0| and A= |0 -5 4| |5 0 -1| |-4 1 0|

We can clearly see that AT=−A which makes A skew-symmetric matrix.

Input: Enter the number of rows and columns: 2 2 Enter the matrix elements: 10 20 20 10 Output: The matrix is symmetric. 10 20 20 10

## Explanation

If the matrix is equal to its transpose, then it’s a symmetric matrix.

Else if it’s transpose is equal to the negative of itself, then the matrix is skew-symmetric. Else it is neither. The result is printed accordingly

The process to check for symmetry of a matrix

The user is asked to enter a number of rows and columns of the matrix.

The elements of the matrix are asked to enter and store in ‘A’. Variables ‘x’ and ‘y’ are initialized as 0.

If the matrix is not equal to its transpose, a temporary variable ‘x’ is assigned 1.

Else if the negative of the matrix is equal to its transpose, a temporary variable ‘y’ is assigned 1.

If x is equal to 0, then the matrix is symmetric. Else if y is equal to 1, the matrix is skew-symmetric.

If neither of the conditions satisfies, the matrix is neither symmetric nor skew-symmetric.

The result is then printed.

## Example

#include<iostream> using namespace std; int main () { int A[10][10], i, j, m, n, x = 0, y = 0; cout << "Enter the number of rows and columns : "; cin >> m >> n; cout << "Enter the matrix elements : "; for (i = 0; i < m; i++) for (j = 0; j < n; j++) cin >> A[i][j]; for (i = 0; i < m; i++) { for( j = 0; j < n; j++) { if (A[i][j] != A[j][i]) x = 1; else if (A[i][j] == -A[j][i]) y = 1; } } if (x == 0) cout << "The matrix is symmetric.

"; else if (y == 1) cout << "The matrix is skew symmetric.

"; else cout << "It is neither symmetric nor skew-symmetric.

"; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) cout << A[i][j] << " "; cout << "

"; } return 0; }

- Related Articles
- Program to check whether given tree is symmetric tree or not in Python
- Program to check whether given matrix is Toeplitz Matrix or not in Python
- How to check whether the tree is symmetric or not using iterative in C#?
- How to check whether the tree is symmetric or not using recursion in C#?
- A square matrix as sum of symmetric and skew-symmetric matrix ?
- Program to check if a matrix is symmetric in C++
- C Program to check if matrix is singular or not
- Program to check if a matrix is Binary matrix or not in C++
- C# program to check whether a list is empty or not
- C++ Program to Check Whether a Number is Prime or Not
- C++ Program to Check Whether a Number is Palindrome or Not
- C Program to Check Whether a Number is Prime or not?
- C++ Program to check whether given password is strong or not
- C++ program to check whether given string is bad or not
- C++ Program to Check Whether a Character is Alphabet or Not