0

exception related bug i guess

please find the bug in the program below and inform me . It would be much appreciated. /* This program can solve 3 equations by using cramers rule. */ //importing modules #include <stdio.h> //creating the fuctions int determinant(int a11, int a12, int a13, int a21, int a22, int a23, int a31, int a32, int a33) { int step_1, step_2, step_3; step_1 = (a22*a33) - (a23*a32); step_2 = (a21*a33) - (a23*a31); step_3 = (a21*a32) - (a31*a22); int det_result = (a11*step_1) + (a13*step_3) - (a12*step_2); return(det_result); } //main function int main () { //getting user input int i; printf("Enter the coefficients of the first equation. Press enter after writing each value to give input.\n => "); int ed1[3] = {}; for (i = 0; i <= 3; i++) { scanf("%d", &ed1[i]); } printf("Enter the coefficients of the second equation. Press enter after writing each value to give input.\n => "); int ed2[3] = {}; for (i = 0; i <= 3; i++) { scanf("%d", &ed2[i]); } printf("Enter the coefficients of the third equation. Press enter after writing each value to give input.\n => "); int ed3[3] = {}; for (i = 0; i <= 3; i++) { scanf("%d", &ed3[i]); } //main mathod int dx, dy, dz, d, x, y, z; d = determinant(ed1[0], ed1[1], ed1[2], ed2[0], ed2[1], ed2[2], ed3[0], ed3[1], ed3[2]); dx = determinant(ed1[3], ed1[1], ed1[2], ed2[3], ed2[1], ed2[2], ed3[3], ed3[1], ed3[2]); dy = determinant(ed1[0], ed1[3], ed1[2], ed2[0], ed2[3], ed2[2], ed3[0], ed3[3], ed3[2]); dz = determinant(ed1[0], ed1[1], ed1[3], ed2[0], ed2[1], ed2[3], ed3[0], ed3[1], ed3[3]); x = dx/d; y = dy/d; z = dz/d; printf("x = %d \ny = %d \nz = %d \n", x, y, z); }

15th Dec 2022, 3:35 PM
Tasnimul Hassan
Tasnimul Hassan - avatar
1 Answer
+ 2
You can ***link*** your code like this: Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code. This way the code is easier to read and people can test it.
15th Dec 2022, 4:31 PM
Lisa
Lisa - avatar