Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given two matrices X_m times n and Y_l times k write a program that conducts the

ID: 3773788 • Letter: G

Question

Given two matrices X_m times n and Y_l times k write a program that conducts the following: Initializes X_m times n and Y_l times k, where {m, n, l, k} are user defined and also its contents. Develop a matrix calculator which evaluates the following using a 'switch' statement and several functions: Show whole program in C++ Z = X + Y Z = X - Y Z = X times Y Z = X times Y^-1 Z = X^-1 Z = cX, where c is a constant det(X) Z = Adjoint (X) Z = X^T The program should have a separate function called 'print' that simply prints the answer and may be called each time to print the result.

Explanation / Answer

program #include<iostream.h>
#include<conio.h>
void main()
{
int a[5][5],b[5][5],t[5][5],i,j,k,l,m,n,z,c[5][5],x,y; //declarations
clrscr();
cout<<"enter the order of the matrix > ";
cin>>x;
cout<<endl<<"enter the 1st matrix elements > ";
for(i=0;i<x;i++)
{
for(j=0;j<x;j++)
{
cin>>a[i][j];
}
}
cout<<endl<<"enter the 2nd matrix elements > ";
for(i=0;i<x;i++)
{
for(j=0;j<x;j++)
{
cin>>b[i][j];
}
}
cout<<endl<<"SUM...."<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<x;j++)
{
cout<<" "<<a[i][j]+b[i][j];
}
cout<<endl;
}
cout<<"enter the order of the 4 matrices > ";
cin>>k;
cin>>l;
cin>>m;
cin>>n;
cout<<endl<<"enter the 1st matrix elements > ";
for(i=0;i<k;i++)
{
for(j=0;j<l;j++)
{
cin>>a[i][j];
}
}
cout<<endl<<"enter the 2nd matrix elements > ";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>b[i][j];
}
}
if(l==m)
{
for(i=0;i<k;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(z=0;z<l;z++)
{
c[i][j]=c[i][j]+(a[i][z]*b[z][j]);
}
}
} }
else
{
cout<<"invalid data....";
}
cout<<endl<<"PRODUCT..."<<endl;
for(i=0;i<k;i++)
{
for(j=0;j<n;j++)
{
cout<<" "<<c[i][j];
}
cout<<endl;
}
cout<<"enter the order of the matrix > ";
cin>>x;
cin>>y;
cout<<endl<<"enter the matrix elements > ";
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
cin>>a[i][j];
}
}
cout<<"matrix..."<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
cout<<" "<<a[i][j];
}
cout<<endl;
}
cout<<endl<<"transpose..."<<endl;
for(i=0;i<y;i++)
{
for(j=0;j<x;j++)
{
t[i][j]=a[j][i];
}
}
for(i=0;i<y;i++)
{
for(j=0;j<x;j++)
{
cout<<" "<<t[i][j];
}
cout<<endl;
}
cout<<endl<<"enter the elements of a 3*3 matrix > ";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
z=(a[0][0]*(a[1][1]*a[2][2])-(a[2][1]*a[1][2]))-(a[0][1]*(a[1][0]*a[2][2])-(a[2][0]*a[1][2]))+(a[0][2]*(a[1][0]*a[2][1])-(a[2][0]*a[1][1]));
cout<<endl<<"determinant = "<<z;
if(z==0)
{
cout<<endl<<"this is a singular matrix...";
}
else
{
cout<<endl<<"this is not a singular matrix...";
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote