/* Matrix Determinant Write a C program that: 1) takes in the elements of a 3x3 matrix from the user 2) calls a function to print the matrix 3) calls another function to compute the determinant of the matrix 4) prints the determinant inside the main function. You can assume that all elements of the matrix will be integers in the range 0-99. The determinant of a 3x3 matrix is given by the following formula: | a b c | | d e f | = a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h | g h i | ============= START OF SAMPLE RUN ======================= Enter row 1 of the matrix> 1 2 3 Enter row 2 of the matrix> 4 11 6 Enter row 3 of the matrix> 10 9 8 Matrix: | 1 2 3| | 4 11 6| |10 9 8| The determinant of the matrix is -132 ============= END OF SAMPLE RUN ======================= */ #include #include int determinant(int a, int b, int c, int d, int e, int f, int g, int h, int i) { return a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h; } void printMatrix(int num1, int num2, int num3, int num4, int num5, int num6, int num7, int num8, int num9) { printf("\n"); printf("Matrix:\t|%2d %2d %2d|\n", num1, num2, num3); printf("\t|%2d %2d %2d|\n", num4, num5, num6); printf("\t|%2d %2d %2d|\n", num7, num8, num9); printf("\n"); } int main() { int num1, num2, num3, num4, num5, num6, num7, num8, num9; printf("Enter row 1 of the matrix> "); scanf("%d %d %d", &num1, &num2, &num3); printf("Enter row 2 of the matrix> "); scanf("%d %d %d", &num4, &num5, &num6); printf("Enter row 3 of the matrix> "); scanf("%d %d %d", &num7, &num8, &num9); int det = determinant(num1, num2, num3, num4, num5, num6, num7, num8, num9); printMatrix(num1, num2, num3, num4, num5, num6, num7, num8, num9); printf("The determinant of the matrix is %d\n", det); system("pause"); }