VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-check-whether-two-matrices-are-equal-or-not/

⇱ C Program to Check Whether Two Matrices Are Equal or Not - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Check Whether Two Matrices Are Equal or Not

Last Updated : 2 Aug, 2022

Here, we will see how to check whether two matrices are equal or not using a C Program

Input: 

First Matrix: 
1, 2, 3, 4
1, 2, 3, 4
1, 2, 3, 4
1, 2, 3, 4

Second matrix:
1, 2, 3, 4
1, 2, 3, 4
1, 2, 3, 4
1, 2, 3, 4

Output: 

Matrices are equal.

Approach:  

For any two matrices to be equal, the number of rows and columns in both the matrices should be equal and the corresponding elements also equal.

Example:


Output
 First Matrix 
 1 2 3 4
 1 2 3 4
 1 2 3 4
 1 2 3 4

 Second Matrix 
 1 2 3 4
 1 2 3 4
 1 2 3 4
 1 2 3 4

 Matrices are equal

Time complexity: O(n2).
Auxiliary space: O(1).

Comment
Article Tags: