# Sum of two matrix – C Program

## Sum of two Matrix – C Program

### Write a c program for sum two dimensional matrix

Sum of two matrix – we enter elements of first matrix and then enter elements of second matrix, then sum of two matrix by position of row and columns of elements.

``````#include <stdio.h>
#include <conio.h>

void main()
{
int first,second10],result, i, j, row, col;

printf("Enter the row size of matrix : \n");
scanf("%d",&row);

printf("Enter the column size of matrix : \n\n");
scanf("%d",&col);

printf("Enter the elements of First matrix :\n");
for(i=0;i<row;i++)
{
for(j=0;i<col;j++)
{
scanf("%d", &first[i][j]);
}

}

printf("\nEnter the elements of Second matrix :\n");
for(i=0;i<row;i++)
{
for(j=0;i<col;j++)
{
scanf("%d", &second[i][j]);
}

}

for(i=0;i<row;i++)
{
for(j=0;i<col;j++)
{
result[i][j]=first[i][j]+second[i][j];
}
}

printf("\n\nThe Sum of two matrix is : \n")
for(i=0;i<row;i++)
{
for(j=0;i<col;j++)
{
printf("%d", result[i][j]);
printf("\t");
}
printf("\n");
}
}``````

The output of sum of two matrix is:

``````Enter the row size of matrix :
3
Enter the column size of matrix :
3

Enter the elements of first matrix :
1
2
3
4
5
6
7
8
9

Enter the elements of second matrix :
1
2
3
4
5
6
7
8
9

The Sum of two matrix is :
2    4    6
8    10   12
14   16   18``````