#include <iostream>
#include <conio.h>

using std::cin;
using std::cout;
using std::endl;



int ShowMatrix()
{
	int row=2; 
	int column=2;
	int matrix[2][2] = { {8, -4} , {-6, 2}  };
   
    cout<<"Matrix is"<<endl;
   for(int a=0; a<row; ++a) 
   
   {
      for(int b=0; b<column; ++b)
      cout<<matrix[a][b]<<"       ";
      cout<<endl;
   }

}

   
   int showTranspose()
{
   int transpose[2][2], row=2, column=2, a, b;
   int matrix[2][2] = { {8, -4} , {-6, 2}  };
   
   cout<<endl;
   for(a=0; a<row; ++a)
   for(b=0; b<column; ++b) 
   
   {
      transpose[b][a] = matrix[a][b];
   }
   
   
   cout<<"Transpose of the given matrix is"<<endl<<endl;
   for(a=0; a<column; ++a) {
      for(b=0; b<row; ++b)
      cout<<transpose[a][b]<<"       ";
      cout<<endl<<endl;
   }
}


int showAdjoint()
{
	  int ch,A2[2][2] = {{8,-4},{-6,2}},AD2[2][2],C2[2][2];

        
//Calculating co-factors of matrix 
        C2[0][0]=A2[1][1]; C2[0][1]=-A2[1][0]; C2[1][0]=-A2[0][1]; C2[1][1]=A2[0][0];
//calculating ad-joint 
        AD2[0][0]=C2[0][0]; AD2[0][1]=C2[1][0]; AD2[1][0]=C2[0][1]; AD2[1][1]=C2[1][1];
        cout<<"Adjoint of the given matrix is "<<endl<<endl;
        cout<<""<<AD2[0][0]<<"       "<<AD2[0][1]<<"\n"""<<AD2[1][0]<<"       "<<AD2[1][1]<<"\n"<<endl;

	
}




int	calculateDeterminant()
{

	int  determMatrix[2][2],	determinant;
	int matrix[2][2] = { {8, -4} , {-6, 2}  };
	
	
	
	determinant = ((matrix[0][0] * matrix[1][1]) - 
					(matrix[0][1] * matrix[1][0]));

 	cout << "Determinant of the given matrix is " << determinant<<endl<<endl;	
}






int main()
{

int inputval;
		
	while (inputval < 3)
	
	{
	
	
	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.";
	cout<<""<<endl;
	
	
	char choice = _getch(); //_getch loads move with one character that the user enters
			                //the code continues after one key is pressed
		
		cout<<choice<<endl;
		
		if(choice == '1') 
		
		{
			ShowMatrix();
            showTranspose ( );
		}
		else if(choice == '2') 
		{
			showAdjoint();
	        calculateDeterminant();
		}
	else 
		{
			inputval= 3;
		}
		
	}
		return 0;
}
  






