help

how to make a program which take 2*2 matrix and out put is ad joint matrix of 2*2???please help
Last edited on
How do you want to input your 2 * 2 matrix? Do you want the user to type it in? Or should it be read from a file?
i want that user type in
This is gonna help you.........
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<conio>

int main()
{
	int i,j,m,n,matrix[2][2],adjoint[2][2];
   cout<<"\n\nEnter the Elements of the Matrix (2*2) -->\n\n\n";
   	for(i=0;i<2;i++)
      	for(j=0;j<2;j++)
         {
         	cout<<"Enter Elements A["<<i<<"]["<<j<<"] : ";
            	cin>>matrix[i][j];
         }

   for(i=1,m=0;i>=0,m<2;i--,m++)
   	for(j=1,n=0;j>=0,n<2;j--,n++)
      {	if(i==j)
         	adjoint[m][n]=matrix[i][j];
         else
         	adjoint[i][j]=-matrix[i][j];
      }
   cout<<"\n\nAdjoint of Matrix is - \n\n";
   	for(i=0;i<2;i++)
      {
      	for(j=0;j<2;j++)
         	cout<<adjoint[i][j]<<"		";
         cout<<endl;
      }
   getch();
   return 0;
}
Topic archived. No new replies allowed.