Addition Of Matrix In C

A matrix is a 2D array with elements in rows and columns. Matrices of the same dimensions (m rows and n columns) can be added;
The sum is a matrix of the same order, obtained by adding corresponding elements.

Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreProgram to Add Two Matrices
The following code can be used for matrix addition in C :
Output
The output of the matrix addition in the C code is as below.
Program Explanation
In the above program,
- We have three matrices: ' mat1, mat2, and result`.
- The matrix mat1 will store the first matrix, the matrix mat2 will store the second matrix, and the result matrix will store the sum of two matrices.
- The user enters the order of matrices, i.e., the number of rows and the number of columns.
- for loops are used to take the matrix elements.
- Once the user enters both matrices, another for loop finds the sum of the two matrices.
- The sum of two matrices is calculated by taking the sum of corresponding elements in both the matrix and stored in the matrix result.
- Finally, the result matrix is printed.
- In this way, we can perform matrix addition in c.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Conclusion
- A matrix with the order mxn can be added with another matrix of the order .
- Adding the corresponding elements in the matrices will give the resultant element.
- The resultant matrix will have the same order as that of the two matrices being added.