Wednesday, November 26, 2008

C Programming Solved - Session 5

17. Print the Upper and Lower triangle of the Matrix:

#include
#include
void main()
{
clrscr();
int arr[3][3];
printf("\nPlease enter the elements of 3x3 matrix:");
for(int i=0; i<3; j="0;" count ="3;" i="0;" j="0;" t="" nlower="" n="" count="2;" i="0;"><3; j="0;">=count)
{ printf("%d\t",arr[i][j]);
}
else
{
printf("\t");
}
}
printf("\n");
count--;
}
getch();
}


-------------------------------------------------------------------

19. Inverse a Matrix:

#include
#include

void main()
{
float A[3][3];// the matrix
float B[3][3];//the transpose of a matrix A
float C[3][3];//the adjunct matrix of transpose of a matrix A not adjunct of A
double X[3][3];//the inverse
int i,j;
float x,n=0;//n is the determinant of A
clrscr();
printf("========== Enter matrix A =============================================\n");
for(i=0;i<3;i++) j="0;j<3;j++)" i="0,j="0;j<3;j++)" j="="2)" j="="1)" i="2,j="0;j<3;j++)" j="="2)" j="="1)" n="="="="="="="="="="" is ="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="="\n" i="0;i<3;i++)" j="0;j<3;j++)" i="0;i<3;i++)" j="0;j<3;j++)">

No comments: