google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program to find the product of two compatible matrices - 2nd puc computer science

Write a program to find the product of two compatible matrices

// Write a program to find the product of two compatible matrices

#include<iostream.h>

#include<conio.h>

void main()

{

int a[5][5],b[5][5],p[5][5],i,j,k,r1,c1,r2,c2;

clrscr();

cout<<"Enter the order of the first matrix:\n";

cin>>r1>>c1;

cout<<"Enter the order of the second matrix:\n";

cin>>r2>>c2;

if(r1==c2)

{

cout<<"Enter the elements of the first matrix:\n";

for(i=0;i<r1;i++)

for(j=0;j<c1;j++)

cin>>a[i][j];

cout<<"Enter the elements of the second matrix:\n";

for(i=0;i<r2;i++)

for(j=0;j<c2;j++)

cin>>b[i][j];

for(i=0;i<r1;i++)

for(j=0;j<c1;j++)

{

p[i][j]=0;

for(k=0;k<c1;k++)

p[i][j]=p[i][j]+a[i][k]*b[k][j];

}

cout<<"The resultant matrix is:\n";

for(i=0;i<r1;i++)

{

for(j=0;j<c1;j++)

cout<<"   "<<p[i][j];

cout<<endl;

}

}

else

cout<<"Matrices are not compatible";

getch();

}

Write a program to find the product of two compatible matrices Write a program to find the product of two compatible matrices Reviewed by Vision Academy on February 27, 2022 Rating: 5

No comments:

CheckOut

Powered by Blogger.