5 9 -2
A = 8 0 5
0 2 8
2 4
B = 0 1
1 3
A x B = 8 23
21 47
8 26
void main()
{
clrscr();
int A[3][3] = { 5, 9, -2,
8,0,5 ,
0,2, 8 };
int B[3][2] = { 2,4 ,
0 , 1,
1,3 } ;
int P[3][2] , i, j, k;
/* ......Product ...... */
for(i = 0; i< 3 ; i++)
for(j = 0 ; j< 2 ; j++)
{
P[i][j] = 0;
for(k = 0; k< n ; k++)
P[i][j] = P[i][j] + A[i][k] * B[k][j];
}
cout<< "\n Matrix A : \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 3 ; j++)
cout<< A[i][j];
cout<< endl;
}
cout<< "\n Matrix B: \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 2 ; j++)
cout<< B[i][j];
cout<< endl;
}
cout<< "\n Product AXB : \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 2 ; j++)
cout<< P[i][j];
cout<< endl;
}
getch();
}
A = 8 0 5
0 2 8
2 4
B = 0 1
1 3
A x B = 8 23
21 47
8 26
#include <iostream.h>
#include <conio.h>
#include<process.h>void main()
{
clrscr();
int A[3][3] = { 5, 9, -2,
8,0,5 ,
0,2, 8 };
int B[3][2] = { 2,4 ,
0 , 1,
1,3 } ;
int P[3][2] , i, j, k;
/* ......Product ...... */
for(i = 0; i< 3 ; i++)
for(j = 0 ; j< 2 ; j++)
{
P[i][j] = 0;
for(k = 0; k< n ; k++)
P[i][j] = P[i][j] + A[i][k] * B[k][j];
}
cout<< "\n Matrix A : \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 3 ; j++)
cout<< A[i][j];
cout<< endl;
}
cout<< "\n Matrix B: \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 2 ; j++)
cout<< B[i][j];
cout<< endl;
}
cout<< "\n Product AXB : \n ";
for( i =0; i< 3 ; i++)
{ for(j = 0; j< 2 ; j++)
cout<< P[i][j];
cout<< endl;
}
getch();
}
No comments:
Post a Comment