C program to check a given matrix is an identity matrix or not
belongs to collection: C language Two Dimensional (Matrix) solved programs/examples
All Answers
total answers (1)
belongs to collection: C language Two Dimensional (Matrix) solved programs/examples
total answers (1)
The identity matrix of size n is the n x n square matrix with ones on the main diagonal and zeros elsewhere.
Given a matrix, we have to check whether the matrix is an identity matrix or not using C program.
Program:
The source code to check a given matrix is an identity matrix or not is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
In the above program, we created two functions isIdentityMatrix() and main() function. The isIdentityMatrix() function is a user defined function, it is used to check a matrix is identity matrix or not.
In the main() function, we created two matrices Matrix1, Matrix2. Then we checked matrices are identity matrices or not using the isIdentityMatrix() function and then we printed the appropriate message on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer