U haven't stated what kind of program u need. Anyways, I'm sending u a C-program for matrix-multiplication. Run it in Turbo C++ IDE compiler & see the output.
/*C-program :demo of matrix-multiplication*/
#include
#include
void main()
{
int a[3][3],b[3][3],c[3][3];
int i,j,k,m,n,p,q;
clrscr();
printf("enter order of matrix A");
scanf("%d%d",&m,&n);
printf("enter order of matrix B");
scanf("%d%d",&p,&q);
if(n!=p)
{
printf("multiplication not possible");
}
else
{
for(i=0;i
{
for(j=0;j
{
printf("enter elements of matrix A");
scanf("%d",&a[i][j]);
}
}
for(i=0;i
{
for(j=0;j
{
printf("enter elements of matrix B");
scanf("%d",&b[i][j]);
}
}
printf("order of matrix C is %dx%d",m,q);
for(i=0;i
{
for(j=0;j
{
c[i][j]=0;
for(k=0;k
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("matrix C is \n");
for(i=0;i
{
for(j=0;j
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
}
getch();
}
2006-09-28 00:54:48
·
answer #1
·
answered by Innocence Redefined 5
·
0⤊
0⤋
Above answer(program) is absolutlly right while u are working on 3*3 matrix multiplication.But if u want to multiply 2*2 matrix then it is very easy,there are also different multiplication.
if A=1 2 3 4 & B=5 6 7 8
given then simply multiply ,think logically as follows
for A memory will assign as
A=A[0][0] A[0][1] A[1][0] A[1][1]
same way for B matrix.
To multiply it
A[0][0]*B[0][0] - A[0][1]*B[0][1]
A[1][0]*B[0][0] - A[1][1]*B[1][1]
I think u should understand its' basic logic then u will be able to make ur own programme.
2006-09-28 09:30:56
·
answer #2
·
answered by Swati 1
·
0⤊
0⤋