C program to do the addition of two matrices

Code:

#include<stdio.h>
void main()
{
int mat1[3][3],mat2[3][3],rmat[3][3];
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter a %dcoloum %drow of matrix1");
scanf("%d",&mat1[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter a %dcoloum %drow of matrix2");
scanf("%d",&mat2[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
rmat[i][j]=mat1[i][j]+mat2[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",rmat[i][j]);
}
printf("\n");
}
}

Comments

Popular posts from this blog

C++ programming toll plaza simulation program