#include #include void main() { int i,j; float A[3][4],B[3][4],temp1,temp2,temp3; clrscr(); printf("Enter the matrix input :\n"); for (i=0;i<3;i++) for (j=0;j<4;j++) scanf("%f",&A[i][j]); clrscr(); printf("The Matrix input was :\n"); for (i=0;i<3;i++) { for (j=0;j<4;j++) printf("%4.2f ",A[i][j]); printf("\n"); } for (i=0;i<4;i++) { B[0][i] = (A[0][i]/A[0][0]); //R1 <- (R1 / R1[1]) B[1][i] = (A[1][i] - (A[1][0]*B[0][i])); //R2 <- R2 - (R2[1]*R1) B[2][i] = (A[2][i] - (A[2][0]*B[0][i])); //R3 <- R3 - (R3[1]*R1) } printf("\nThe Matrix output after First Pass is :\n"); for (i=0;i<3;i++) { for (j=0;j<4;j++) printf("%4.2f ",B[i][j]); printf("\n"); } temp1 = B[1][1]; temp2 = B[2][1]; for (i=1;i<4;i++) { B[1][i] = (B[1][i]/temp1); //R2 <- (R2 / R2[2]) B[2][i] = (B[2][i] - (temp2*B[1][i])); //R3 <- R3 - (R3[2]*R2) } printf("\nThe Matrix output after Second Pass is :\n"); for (i=0;i<3;i++) { for (j=0;j<4;j++) printf("%4.2f ",B[i][j]); printf("\n"); } temp1 = B[2][2]; for (i=2;i<4;i++) { B[2][i] = (B[2][i]/temp1); //R3 <- (R3 / R3[3]) } printf("\nThe Matrix output in Row Echlon Form is :\n"); for (i=0;i<3;i++) { for (j=0;j<4;j++) printf("%4.2f ",B[i][j]); printf("\n"); } temp3=B[2][3]; temp2=B[1][3] - (temp3*B[1][2]); temp1=B[0][3] - (temp3*B[0][2]) - (temp2*B[0][1]); printf("\nSolutions :\n X = %4.2f\n Y = %4.2f\n Z = %4.2f\n",temp1,temp2,temp3); printf("Press Any Key To Exit"); getch(); }