AlgoGenesis / C

AlgoGenesis is a centralized open-source platform dedicated to providing optimized and well-documented algorithm implementations in C. Perfect for both beginners and advanced users, this repository serves as a comprehensive learning resource for solving algorithmic challenges.
MIT License
81 stars 253 forks source link

[Identity Matrix In C] #1302

Open DinkyRajpoot56 opened 2 hours ago

DinkyRajpoot56 commented 2 hours ago

Issue will be closed if:

1) You mention more than one algorithm. You can create a separate issue for each algorithm once the current one is completed.
2) You propose an algorithm that is already present or has been mentioned in a previous issue.
3) You create a new issue without completing your previous issue.

Note: These actions will be taken seriously. Failure to follow the guidelines may result in the immediate closure of your issue.


Name:

[Identity Matrix]

About:

This C Program checks a given Matrix is an Identity Matrix. Identity matrix is a square matrix with 1’s along the diagonal from upper left to lower right and 0’s in all other positions. If it satisfies the structure as explained before then the matrix is called as identity matrix.

Problem Solution

  1. Create a matrix (2D array) and define its elements according to its size.
  2. Two check whether the matrix is an identity matrix or not, run a nested for loop with two iterators.
  3. Using two iterators, locate each position of matrix and check whether the right diagonal have all 1s with remaining elements as 0s.
  4. Set a flag variable 1 if it matches the above condition, otherwise it will be 0.
  5. Print Identity matrix if flag is 1.

Labels:

new algorithm, gssoc-ext, hacktoberfest, level1


Assignees:

Monik2002 commented 2 hours ago

/assign