Here all the Matrix programs in c using array are available. This program will add two matrices, subtract two matrices, and multiply two matrices.

## Addition of matrices in c

In this Matrix program in c using an array, we will add two matrices. First, we insert numbers in the matrix entered by the user in Matrix A and Matrix B using for loop. Now we take another matrix that contains the addition of corresponding elements of matrices using for loop.
```#include <stdio.h>
int main()
{
int C, A, B, i, j, ch;
printf("n Matrix An");
printf("n Enter the numbers you want to insert :");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("t");
scanf("%d", &ch);
A[i][j] = ch;
}
}
printf("n Matrix A:n");

for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("%d", A[i][j]);
printf("t");
}
printf("n");
}
printf("nn Matrix B");
printf("n Enter the numbers you want to insert in the matrix B:n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("t");
scanf("%d", &ch);
B[i][j] = ch;
}
}
printf("n Matrix B:n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("%d", B[i][j]);
printf("t");
}
printf("n");
}
printf("n A+B=n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
C[i][j] = A[i][j] + B[i][j];
printf("%d", C[i][j]);
printf("t");
}
printf("n");
}
return 0;
}```

## Program to add Two Matrix in C

Approach for C program for addition of matrices:

1. Take input of both the matrices from the user.
2. Using Nested for loop, we add the corresponding elements of matrices. Run an outer loop from i=0 to number to rows & inner loop will run from j=0 to the number of columns. For this, we use the following statement:
C[i][j]= A[i][j]+B[i][j];

## Subtraction of two matrices in c

In this matrix program in c using an array, we will subtract two matrices. First, we insert numbers in the matrix entered by the user in Matrix A and Matrix B using for loop. Now we take another matrix that contains subtraction of corresponding elements of matrices using for loop.

```#include <stdio.h>
int main()
{
int C, A, B, i, j, ch;
printf("n Matrix An");
printf("n Enter the numbers you want to insert :");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("t");
scanf("%d", &ch);
A[i][j] = ch;
}
}
printf("n Matrix A:n");

for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("%d", A[i][j]);
printf("t");
}
printf("n");
}
printf("nn Matrix B");
printf("n Enter the numbers you want to insert in the matrix B:n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("t");
scanf("%d", &ch);
B[i][j] = ch;
}
}
printf("n Matrix B:n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
printf("%d", B[i][j]);
printf("t");
}
printf("n");
}
printf("n A+B=n");
for (i = 0; i < 3; i++)
{
for (j = 0; j <3; j++)
{
C[i][j] = A[i][j] - B[i][j];
printf("%d", C[i][j]);
printf("t");
}
printf("n");
}
return 0;
}```

Approach for C program for subtraction of matrices:

1. Using Nested for loop, we insert the matrices element.
2.  We subtract the corresponding elements of matrices.
3. Run two loops, i ->0 to n and j->0 to n.
4. Use C[i][j]= A[i][j]-B[i][j]; to perform subtraction of corresponding elements.

## Matrix program in c using array

Matrix: A matrix is an ordered array of numbers. We can only perform arithmetic operations like addition, subtraction, and multiplication of matrices in a square matrix. Square matrices are those which have the same number of rows and columns.

Following is the example of the square matrix: –
Matrix A
A A A A A A A A A
We use a nested for loop to make a Matrix program in c using an array.