addition of two matrices

ssuserfa2300 863 views 2 slides Nov 29, 2013
Slide 1
Slide 1 of 2
Slide 1
1
Slide 2
2

About This Presentation

for more visit www.cncreate.blogspot.in


Slide Content

This program let you to add two matrices of same size and
displaying the elements of resultant matrix.
void main()
{
int a[2][2], b[2][2], c[2][2];

printf("enter the elements of matrix a\n");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the elements of matrix b\n");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
scanf("%d",&b[i][j]);
}
}
printf("the sum of two matrices is \n");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
printf("%d\n",a[i][j] + b[i][j]);
}
}
}
output
enter the elements of matrix a
1
2
3
4
enter the elements of matrix b

1
2
3
4
the sum of two matrices is
2
4
6
8