Monday, January 4, 2010

Program to find multiplication of two matrices.

#include
#include

void main()
{
int a[3][2],b[3][2],c[3][2],i,j;
clrscr();
printf("enter value for 1 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
printf("enter value for 2 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
c[i][j]=a[i][j]*b[i][j];
}
printf("matrix is\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(" %d ",c[i][j]);
}
printf("\n");
}
getch();
}



Output:
enter value for 1 matrix: 7
8
9
4
5
6
enter value for 2 matrix: 3
2
1
2
5
6
matrix is
21  16
9     8
25  36

No comments:

Post a Comment