### Overview:

A matrix is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns. In this article, I will introduce you to the mathematical concept of Matrix and matrix Addition. After that, I will explain What is an array? and What is a Multidimensional Array? Moreover, I will show a Demonstration of the addition of matrices. At last, I will show a C program to add two matrices with output in front of you.

### Table of contents:

- What is Matrix?
- What is matrix Addition?
- What is an Array?
- What is multi dimensional array?
- Demonstration for addition of matrices.
- Logic for matrix addition
- c program for matrix addition
- Conclusion

### What is Matrix?

A matrix is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns. The matrix of r rows and c columns is known as the r X c matrix. Matrices are often denoted using capital roman letters such as A, B, and C. For example,

### What is matrix Addition?

Matrix addition is the operation of adding two matrices by adding the corresponding entries together. Matrix addition is done element-wise (entry-wise) i.e. Sum of two matrices. A and B of size mXn is defined by:

(A + B) = Aij + Bij (Where 1 ≤ i ≤ m and 1 ≤ j ≤ n)

### What is an Array?

An array is a container for the collection of items that stores these items at contiguous memory locations. An array is a variable that can store multiple values. For example, if you want to store 100 integers in a single variable then you can create an array for it.

### What is a multi-dimensional array?

A multidimensional array is an array of arrays. You can declare a two-dimensional (2d) array. For example, float x[3][4]; Similarly, you can declare a three-dimensional (3d) array. For example, float y[2][4][3];

### Demonstration for addition of matrices.

### The logic for matrix addition

To add two matrices, i.e., compute their sum and print it. A user inputs their orders (number of rows and columns) and the elements of these two matrices. For example, if the order is 2, 2, i.e., two rows and two columns, and the matrices are as follows:

First matrix A =

1 1 2

3 1 4

Second matrix B=

4 1 5

-1 5 3

The Sum of these two matrices is:

1+4 1+1 2+5

3-1 1+5 4+3

=

5 2 7

2 6 7

The main logic to write a C program for the Matrix Addition is as follows:

**Step 1:**Take 3 arrays such as first[][], second[][], and sum[][].**Step 2:**Accept the number of rows and columns for the two arrays.**Step 3:**Then, accept elements of these two arrays.**Step 4:**After all, add the corresponding elements of the arrays and store its elements to the new array and display their elements.

### C program for matrix addition

#include <stdio.h> int main() { int r, c, i, j, first[10][10], second[10][10], sum[10][10]; printf("Enter the number of rows and columns of matrix\n"); scanf("%d%d", &r, &c); printf("Enter the elements of first matrix\n"); for (i = 0; i < r; i++) for (j = 0; j < c; j++) scanf("%d", &first[i][j]); printf("Enter the elements of second matrix\n"); for (i = 0; i < r; i++) for (j = 0 ; j < c; j++) scanf("%d", &second[i][j]); printf("Sum of entered matrices:-\n"); for (i = 0; i < r; i++) { for (j = 0 ; j < c; j++) { sum[i][j] = first[i][j] + second[i][j]; printf("%d\t", sum[i][j]); } printf("\n"); } return 0; }

**Conclusion: **

This Program shows matrix addition through the addition of corresponding elements of the matrices.