matrix addition11.html
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
int m1[2][2],m2[2][2],res[2][2];
printf("Enter the elements of your first matrix:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&m1[i][j]);
}
}
printf("\nEnter the elements of your second matrix:");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&m2[i][j]);
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
res[i][j]=m1[i][j]+m2[i][j];
}
}
printf(" \nthe addition of these matrices is:\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d ",res[i][j]);
if(j==1)
printf("\n");
}
}
getch();
return 0;
}
0 Comments