# CS 201 – Current Assignment Solution No. 2 Solved # 2021

2
75

CS 201 – Current Assignment Solution No. 2 Solved # 2021

#include <iostream>

#include <conio.h>

using namespace std;

int ShowMatrix()

{

int row=2, column=2;

int matrix = { {8, -4} , {-6, 2} };

cout<<“The matrix is:”<<endl;

for(int i=0; i<row; ++i) {

for(int j=0; j<column; ++j)

cout<<matrix[i][j]<<” “;

cout<<endl;

}

}

int showTranspose ( )

{

int transpose, row=2, column=2, i, j;

int matrix = { {8, -4} , {-6, 2} };

cout<<endl;

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

for(j=0; j<column; ++j) {

transpose[j][i] = matrix[i][j];

}

cout<<“The transpose of the matrix is:”<<endl;

for(i=0; i<column; ++i) {

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

cout<<transpose[i][j]<<” “;

cout<<endl;

}

}

int calculateDeterminant()

{

int determMatrix, determinant;

int matrix = { {8, -4} , {-6, 2} };

determinant = ((matrix * matrix) –

(matrix * matrix));

cout << “\nThe Determinant of 2 * 2 Matrix = ” << determinant;

}

{

//Calculating cofactors of a matrix of order 2×2

C2=A2; C2=-A2; C2=-A2; C2=A2;

//calculating adjoint of the matrix of order 2×2

cout<<“\n\nAdjoint of A is :- \n\n”;

}

int main()

{

int choice = 0;

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.”;

cin>>choice;

CS 201 – Current Assignment Solution No. 2 Solved # 2021

if (choice ==1)

{

ShowMatrix();

showTranspose ( );

}

else if (choice == 2)

{

calculateDeterminant();

}

else

system(“pause”);

}

CS 201 – Current Assignment Solution No. 2 Solved # 2021

SHARE

1. Teri
2. Abel