Professional Documents
Culture Documents
Assignment no:2
Solution
19/June/2021
Problem Statement
A matrix is given in source data. You have to write user defined functions and create a menu in C++ keeping
in mind the following requirements:
Source data:
(Use two dimensional array to store following matrix)
8 −4
[ ]
−6 2
Instructions to write C++ program:
➢ Write functions to display the matrix; find transpose, adjoint and determinant of the matrix.
Following function names should be used for consistency.
To display matrix showMatrix ( );
cout<<endl;
} // end of showMatrix function
int main ()
{
int arr [2][2];
arr [0][0] = 8;
arr [0][1] = -4;
arr [1][0] = -6;
arr [1][1] = 2;
int ch;
do {
cout<<"Enter your choice"<<endl;
cout<<"Press 1 to display the matrix and its transpose. "<<endl;
cout<<"Press 2 to find adjoint and determinant of the matrix."<<endl;
cout<<"Press any other key to exit."<<endl;
cin>>ch;
if(ch==1)
{
cout << "Matrix is";
showMatrix(arr);
showTranspose(arr);
}
else if (ch==2)
{
originalMatrix(arr);
showAdjoint(arr);
originalMatrix(arr);
calculateDeterminant(arr);
cout<<endl;
}
else
{
return 0;
}
}
while(true);
return 0;
}